/*      */ package com.zimbra.qa.unittest;
/*      */ 
/*      */ import com.zimbra.common.account.Key.AccountBy;
/*      */ import com.zimbra.common.service.ServiceException;
/*      */ import com.zimbra.cs.account.Account;
/*      */ import com.zimbra.cs.account.Cos;
/*      */ import com.zimbra.cs.account.DistributionList;
/*      */ import com.zimbra.cs.account.Domain;
/*      */ import com.zimbra.cs.account.NamedEntry;
/*      */ import com.zimbra.cs.account.Provisioning;
/*      */ import com.zimbra.cs.account.SearchDirectoryOptions;
/*      */ import com.zimbra.cs.account.SearchDirectoryOptions.ObjectType;
/*      */ import com.zimbra.cs.account.Signature;
/*      */ import com.zimbra.cs.account.soap.SoapProvisioning;
/*      */ import java.io.PrintStream;
/*      */ import java.util.HashMap;
/*      */ import java.util.List;
/*      */ import java.util.Map;
/*      */ import java.util.Set;
/*      */ 
/*      */ public class TestProvisioning extends junit.framework.TestCase
/*      */ {
/*      */   private static final boolean TEST_STARTTLS = false;
/*      */   private Provisioning mProv;
/*      */   com.zimbra.cs.account.ldap.LdapProv mLdapProv;
/*      */   CustomProvTester mCustomProvTester;
/*      */   SoapProvisioning mSoapProv;
/*      */   private String TEST_ID;
/*      */   private String PRE_AUTH_KEY;
/*      */   private String PASSWORD;
/*      */   private String SPECIAL_CHARS_ALLOWED_IN_DOMAIN;
/*      */   private String SPECIAL_CHARS_ALLOWED_IN_USER_PART;
/*      */   private String COS_NAME;
/*      */   private String DOMAIN_NAME;
/*      */   private String DOMAIN_NAME_SPECIAL_CHARS;
/*      */   private String OTHER_DOMAIN_NAME;
/*      */   private String SERVER_NAME;
/*      */   private String ZIMLET_NAME;
/*      */   private String BASE_DN_PSEUDO_ATTR;
/*      */   private String NEW_NAME;
/*      */   private String NEW_EMAIL;
/*      */   private String NEW_EMAIL_IN_OTHER_DOMAIN;
/*      */   private String DEFAULT_LDAP_ADMIN_USER;
/*      */   private String ADMIN_USER;
/*      */   private String ADMIN_EMAIL;
/*      */   private String ACCT_USER;
/*      */   private String ACCT_EMAIL;
/*      */   private String ACCT_USER_SPECIAL_CHARS;
/*      */   private String ACCT_EMAIL_SPECIAL_CHARS;
/*      */   private String ACCT_ALIAS_USER;
/*      */   private String ACCT_ALIAS_EMAIL;
/*      */   private String ACCT_ALIAS_AFTER_ACCOUNT_RENAME_TO_OTHER_DMAIN_EMAIL;
/*      */   private String ACCT_ALIAS_IN_OTHER_DOMAIN_USER;
/*      */   private String ACCT_ALIAS_IN_OTHER_DOMAIN_EMAIL;
/*      */   private String ACCT_ALIAS_IN_OTHER_DOMAIN_AFTER_ACCOUNT_RENAME_TO_ORIG_DOMAIN_EMAIL;
/*      */   private String ACCT_FULL_NAME;
/*      */   private String ACCT_NAMING_ATTR;
/*      */   private String ACCT_NAMING_ATTR_VALUE;
/*      */   private String ACCT_BASE_DN;
/*      */   private String CR_USER;
/*      */   private String CR_EMAIL;
/*      */   private String CR_ALIAS_USER;
/*      */   private String CR_ALIAS_EMAIL;
/*      */   private String DL_USER;
/*      */   private String DL_EMAIL;
/*      */   private String DL_USER_SPECIAL_CHARS;
/*      */   private String DL_EMAIL_SPECIAL_CHARS;
/*      */   private String DL_ALIAS_USER;
/*      */   private String DL_ALIAS_EMAIL;
/*      */   private String DL_NESTED_USER;
/*      */   private String DL_NESTED_EMAIL;
/*      */   private String DL_NESTED_ALIAS_USER;
/*      */   private String DL_NESTED_ALIAS_EMAIL;
/*      */   private String DATA_SOURCE_NAME;
/*      */   private String IDENTITY_NAME;
/*      */   private String SIGNATURE_NAME;
/*      */   private String SIGNATURE_VALUE;
/*      */   private String SIGNATURE_VALUE_MODIFIED;
/*      */   
/*      */   public TestProvisioning()
/*      */   {
/*   82 */     this.BASE_DN_PSEUDO_ATTR = "ldap.baseDN";
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   public void setUp()
/*      */     throws Exception
/*      */   {
/*  134 */     this.mProv = Provisioning.getInstance();
/*  135 */     assertTrue(this.mProv instanceof com.zimbra.cs.account.ldap.LdapProv);
/*  136 */     this.mLdapProv = ((com.zimbra.cs.account.ldap.LdapProv)this.mProv);
/*  137 */     this.mCustomProvTester = new CustomProvTester(this.mProv);
/*      */     
/*  139 */     this.mSoapProv = new SoapProvisioning();
/*  140 */     this.mSoapProv.soapSetURI(TestUtil.getAdminSoapUrl());
/*  141 */     this.mSoapProv.soapZimbraAdminAuthenticate();
/*      */     
/*      */ 
/*  144 */     this.TEST_ID = TestProvisioningUtil.genTestId();
/*      */     
/*  146 */     this.PRE_AUTH_KEY = com.zimbra.cs.account.PreAuthKey.generateRandomPreAuthKey();
/*  147 */     this.PASSWORD = "test123";
/*      */     
/*  149 */     this.SPECIAL_CHARS_ALLOWED_IN_DOMAIN = "/";
/*  150 */     this.SPECIAL_CHARS_ALLOWED_IN_USER_PART = "/";
/*      */     
/*  152 */     this.COS_NAME = ("cos-" + this.TEST_ID);
/*      */     
/*      */ 
/*  155 */     this.DOMAIN_NAME = TestProvisioningUtil.baseDomainName("domain", this.TEST_ID);
/*      */     
/*      */ 
/*  158 */     this.DOMAIN_NAME_SPECIAL_CHARS = TestProvisioningUtil.baseDomainName("domain-special", this.TEST_ID);
/*      */     
/*  160 */     this.OTHER_DOMAIN_NAME = ("other-" + this.DOMAIN_NAME);
/*  161 */     this.SERVER_NAME = ("server-" + this.TEST_ID);
/*  162 */     this.ZIMLET_NAME = ("zimlet-" + this.TEST_ID);
/*      */     
/*  164 */     this.NEW_NAME = "newname";
/*  165 */     this.NEW_EMAIL = (this.NEW_NAME + "-" + this.TEST_ID + "@" + this.DOMAIN_NAME);
/*  166 */     this.NEW_EMAIL_IN_OTHER_DOMAIN = (this.NEW_NAME + "-" + this.TEST_ID + "@" + this.OTHER_DOMAIN_NAME);
/*      */     
/*  168 */     this.DEFAULT_LDAP_ADMIN_USER = com.zimbra.common.localconfig.LC.zimbra_ldap_user.value();
/*  169 */     this.ADMIN_USER = "admin";
/*  170 */     this.ADMIN_EMAIL = (this.ADMIN_USER + "@" + this.DOMAIN_NAME);
/*  171 */     this.ACCT_USER = "acct-1";
/*  172 */     this.ACCT_EMAIL = (this.ACCT_USER + "@" + this.DOMAIN_NAME);
/*  173 */     this.ACCT_USER_SPECIAL_CHARS = ("acct-special-chars-" + this.SPECIAL_CHARS_ALLOWED_IN_USER_PART);
/*  174 */     this.ACCT_EMAIL_SPECIAL_CHARS = (this.ACCT_USER_SPECIAL_CHARS + "@" + this.DOMAIN_NAME_SPECIAL_CHARS);
/*  175 */     this.ACCT_ALIAS_USER = ("alias-of-" + this.ACCT_USER);
/*  176 */     this.ACCT_ALIAS_EMAIL = (this.ACCT_ALIAS_USER + "@" + this.DOMAIN_NAME);
/*  177 */     this.ACCT_ALIAS_AFTER_ACCOUNT_RENAME_TO_OTHER_DMAIN_EMAIL = (this.ACCT_ALIAS_USER + "@" + this.OTHER_DOMAIN_NAME);
/*  178 */     this.ACCT_ALIAS_IN_OTHER_DOMAIN_USER = (this.ACCT_ALIAS_USER + "-in-other-domain");
/*  179 */     this.ACCT_ALIAS_IN_OTHER_DOMAIN_EMAIL = (this.ACCT_ALIAS_IN_OTHER_DOMAIN_USER + "@" + this.OTHER_DOMAIN_NAME);
/*  180 */     this.ACCT_ALIAS_IN_OTHER_DOMAIN_AFTER_ACCOUNT_RENAME_TO_ORIG_DOMAIN_EMAIL = (this.ACCT_ALIAS_IN_OTHER_DOMAIN_USER + "@" + this.DOMAIN_NAME);
/*  181 */     this.ACCT_FULL_NAME = "Phoebe Shao";
/*      */     
/*  183 */     this.ACCT_NAMING_ATTR = com.zimbra.common.localconfig.LC.get("ldap_dit_naming_rdn_attr_user");
/*  184 */     if (com.zimbra.common.util.StringUtil.isNullOrEmpty(this.ACCT_NAMING_ATTR))
/*  185 */       this.ACCT_NAMING_ATTR = "uid";
/*  186 */     this.ACCT_NAMING_ATTR_VALUE = namingAttrValue(this.ACCT_USER);
/*      */     
/*  188 */     this.ACCT_BASE_DN = "ou=grp1,ou=mail,o=Comcast";
/*      */     
/*  190 */     this.CR_USER = "cr-1";
/*  191 */     this.CR_EMAIL = (this.CR_USER + "@" + this.DOMAIN_NAME);
/*  192 */     this.CR_ALIAS_USER = ("alias-of-" + this.CR_USER);
/*  193 */     this.CR_ALIAS_EMAIL = (this.CR_ALIAS_USER + "@" + this.DOMAIN_NAME);
/*      */     
/*  195 */     this.DL_USER = "dl-1";
/*  196 */     this.DL_EMAIL = (this.DL_USER + "@" + this.DOMAIN_NAME);
/*  197 */     this.DL_USER_SPECIAL_CHARS = ("dl-special-chars-" + this.SPECIAL_CHARS_ALLOWED_IN_USER_PART);
/*  198 */     this.DL_EMAIL_SPECIAL_CHARS = (this.DL_USER_SPECIAL_CHARS + "@" + this.DOMAIN_NAME_SPECIAL_CHARS);
/*  199 */     this.DL_ALIAS_USER = ("alias-of" + this.DL_USER);
/*  200 */     this.DL_ALIAS_EMAIL = (this.DL_ALIAS_USER + "@" + this.DOMAIN_NAME);
/*  201 */     this.DL_NESTED_USER = "dl-nested";
/*  202 */     this.DL_NESTED_EMAIL = (this.DL_NESTED_USER + "@" + this.DOMAIN_NAME);
/*  203 */     this.DL_NESTED_ALIAS_USER = ("alias-of-" + this.DL_NESTED_USER);
/*  204 */     this.DL_NESTED_ALIAS_EMAIL = (this.DL_NESTED_ALIAS_USER + "@" + this.DOMAIN_NAME);
/*      */     
/*  206 */     this.DATA_SOURCE_NAME = "datasource-1";
/*  207 */     this.IDENTITY_NAME = "identity-1";
/*  208 */     this.SIGNATURE_NAME = "signature-1";
/*      */     
/*  210 */     this.SIGNATURE_VALUE = "this is my signature";
/*  211 */     this.SIGNATURE_VALUE_MODIFIED = "this is my signature MODIFIED";
/*      */   }
/*      */   
/*      */   static class Flag {
/*  215 */     private static Set<String> sNeedLdapPaging = new java.util.HashSet();
/*      */     
/*      */     static {
/*  218 */       sNeedLdapPaging.add("getAllAdminAccounts");
/*  219 */       sNeedLdapPaging.add("getAllAccounts_domain");
/*  220 */       sNeedLdapPaging.add("getAllAccounts_domain_visitor");
/*  221 */       sNeedLdapPaging.add("getAllAccounts_domain_server_visitor");
/*  222 */       sNeedLdapPaging.add("getAllCalendarResources_domain");
/*  223 */       sNeedLdapPaging.add("getAllCalendarResources_domain_visitor");
/*  224 */       sNeedLdapPaging.add("getAllDistributionLists");
/*  225 */       sNeedLdapPaging.add("getDistributionLists_account");
/*  226 */       sNeedLdapPaging.add("getDistributionLists_account_directonly_via");
/*  227 */       sNeedLdapPaging.add("inDistributionList");
/*  228 */       sNeedLdapPaging.add("searchAccounts");
/*  229 */       sNeedLdapPaging.add("searchAccounts_domain");
/*  230 */       sNeedLdapPaging.add("searchCalendarResources");
/*  231 */       sNeedLdapPaging.add("searchCalendarResources_domain");
/*  232 */       sNeedLdapPaging.add("searchDirectory");
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */     static boolean needLdapPaging(String methodName)
/*      */     {
/*  245 */       return false;
/*      */     }
/*      */   }
/*      */   
/*      */   class CustomProvTester {
/*      */     Provisioning mProv;
/*      */     boolean mIsCustomProv;
/*      */     
/*      */     CustomProvTester(Provisioning prov) {
/*  254 */       this.mProv = prov;
/*  255 */       this.mIsCustomProv = (prov instanceof com.zimbra.cs.account.ldap.custom.CustomLdapProvisioning);
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */     public void cleanup()
/*      */       throws Exception
/*      */     {
/*  264 */       System.out.println("Cleanup...");
/*      */       
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  278 */       SearchDirectoryOptions options = new SearchDirectoryOptions();
/*  279 */       options.setTypes(new SearchDirectoryOptions.ObjectType[] { SearchDirectoryOptions.ObjectType.accounts, SearchDirectoryOptions.ObjectType.resources, SearchDirectoryOptions.ObjectType.distributionlists });
/*      */       
/*      */ 
/*      */ 
/*  283 */       List<NamedEntry> list = this.mProv.searchDirectory(options);
/*      */       
/*  285 */       for (NamedEntry entry : list) {
/*  286 */         if ((entry instanceof com.zimbra.cs.account.CalendarResource)) {
/*  287 */           this.mProv.deleteCalendarResource(entry.getId());
/*  288 */         } else if ((entry instanceof com.zimbra.cs.account.Alias)) {
/*  289 */           this.mProv.removeAlias((Account)null, entry.getName());
/*  290 */         } else if ((entry instanceof Account)) {
/*  291 */           this.mProv.deleteAccount(entry.getId());
/*  292 */         } else if ((entry instanceof DistributionList)) {
/*  293 */           this.mProv.deleteDistributionList(entry.getId());
/*      */         } else {
/*  295 */           throw new Exception("unexpected entry type: " + entry.getClass().getCanonicalName());
/*      */         }
/*      */       }
/*      */       
/*  299 */       options = new SearchDirectoryOptions();
/*  300 */       options.setTypes(new SearchDirectoryOptions.ObjectType[] { SearchDirectoryOptions.ObjectType.accounts, SearchDirectoryOptions.ObjectType.aliases, SearchDirectoryOptions.ObjectType.resources, SearchDirectoryOptions.ObjectType.distributionlists });
/*      */       
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  306 */       list = this.mProv.searchDirectory(options);
/*  307 */       junit.framework.Assert.assertEquals(0, list.size());
/*      */     }
/*      */     
/*      */     public boolean isCustom()
/*      */     {
/*  312 */       return this.mIsCustomProv;
/*      */     }
/*      */     
/*      */     public void addAttr(Map<String, Object> attrs, String pseudoAttr, String value) {
/*  316 */       if (!this.mIsCustomProv) {
/*  317 */         return;
/*      */       }
/*  319 */       attrs.put(pseudoAttr, value);
/*      */     }
/*      */     
/*      */     private void verifyDn(com.zimbra.cs.account.Entry entry, String dn) throws Exception {
/*  323 */       if (!this.mIsCustomProv) {
/*  324 */         return;
/*      */       }
/*  326 */       junit.framework.Assert.assertTrue(entry instanceof com.zimbra.cs.account.ldap.entry.LdapEntry);
/*  327 */       junit.framework.Assert.assertEquals(dn, ((com.zimbra.cs.account.ldap.entry.LdapEntry)entry).getDN());
/*      */     }
/*      */     
/*      */     public boolean verifyAccountCountForDomainBasedSearch() {
/*  331 */       if (!this.mIsCustomProv) {
/*  332 */         return true;
/*      */       }
/*  334 */       return true;
/*      */     }
/*      */     
/*      */     public boolean verifyDLCountForDomainBasedSearch() {
/*  338 */       if (!this.mIsCustomProv) {
/*  339 */         return true;
/*      */       }
/*  341 */       return false;
/*      */     }
/*      */     
/*      */     public boolean verifyAliasCountForDomainBasedSearch() {
/*  345 */       if (!this.mIsCustomProv) {
/*  346 */         return true;
/*      */       }
/*  348 */       return false;
/*      */     }
/*      */   }
/*      */   
/*      */   private class TestVisitor implements com.zimbra.cs.account.NamedEntry.Visitor {
/*      */     private TestVisitor() {}
/*      */     
/*  355 */     List<NamedEntry> mVisited = new java.util.ArrayList();
/*      */     
/*      */     public void visit(NamedEntry entry) throws ServiceException {
/*  358 */       this.mVisited.add(entry);
/*      */     }
/*      */     
/*      */     public List<NamedEntry> visited() {
/*  362 */       return this.mVisited;
/*      */     }
/*      */   }
/*      */   
/*      */ 
/*      */   private List<NamedEntry> searchAccountsInDomain(Domain domain)
/*      */     throws ServiceException
/*      */   {
/*  370 */     SearchDirectoryOptions options = new SearchDirectoryOptions();
/*      */     
/*  372 */     options.setTypes(new SearchDirectoryOptions.ObjectType[] { SearchDirectoryOptions.ObjectType.accounts });
/*  373 */     options.setDomain(domain);
/*  374 */     options.setFilterString(com.zimbra.cs.ldap.ZLdapFilterFactory.FilterId.UNITTEST, null);
/*  375 */     return this.mProv.searchDirectory(options);
/*      */   }
/*      */   
/*      */   private List<NamedEntry> searchAliasesInDomain(Domain domain) throws ServiceException {
/*  379 */     SearchDirectoryOptions options = new SearchDirectoryOptions();
/*      */     
/*  381 */     options.setTypes(new SearchDirectoryOptions.ObjectType[] { SearchDirectoryOptions.ObjectType.aliases });
/*  382 */     options.setDomain(domain);
/*  383 */     options.setFilterString(com.zimbra.cs.ldap.ZLdapFilterFactory.FilterId.UNITTEST, null);
/*  384 */     return this.mProv.searchDirectory(options);
/*      */   }
/*      */   
/*      */   public static class TestCustomAuth extends com.zimbra.cs.account.auth.ZimbraCustomAuth
/*      */   {
/*      */     Account mTheOnlyAcctThatCanAuth;
/*      */     String mTheOnlyPasswordIKnowAbout;
/*      */     
/*      */     TestCustomAuth(Account account, String password) {
/*  393 */       this.mTheOnlyAcctThatCanAuth = account;
/*  394 */       this.mTheOnlyPasswordIKnowAbout = password;
/*      */     }
/*      */     
/*      */     private boolean verifyArgs(List<String> args) {
/*  398 */       if ((args.size() == 6) && (((String)args.get(0)).equals("http://blah.com:123")) && (((String)args.get(1)).equals("green")) && (((String)args.get(2)).equals(" ocean blue   ")) && (((String)args.get(3)).equals("")) && (((String)args.get(4)).equals("yelllow")) && (((String)args.get(5)).equals("")))
/*      */       {
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  405 */         return true;
/*      */       }
/*  407 */       return false;
/*      */     }
/*      */     
/*      */     public void authenticate(Account acct, String password, Map<String, Object> context, List<String> args) throws Exception {
/*  411 */       String acOrigClientIp = (String)context.get("ocip");
/*  412 */       String acRemoteIp = (String)context.get("remoteip");
/*  413 */       String acNamePassedIn = (String)context.get("anp");
/*  414 */       com.zimbra.cs.account.auth.AuthContext.Protocol acProto = (com.zimbra.cs.account.auth.AuthContext.Protocol)context.get("proto");
/*      */       
/*      */ 
/*  417 */       if ((acct.getName().equals(this.mTheOnlyAcctThatCanAuth.getName())) && (password.equals(this.mTheOnlyPasswordIKnowAbout)) && (verifyArgs(args)))
/*      */       {
/*      */ 
/*  420 */         return;
/*      */       }
/*  422 */       throw new Exception("auth failed by TestCustomAuth for " + acct.getName() + " password " + password);
/*      */     }
/*      */   }
/*      */   
/*      */   private void setDefaultDomain(String domain) throws Exception
/*      */   {
/*  428 */     Map<String, Object> confAttrs = new HashMap();
/*  429 */     confAttrs.put("zimbraDefaultDomainName", domain);
/*  430 */     this.mProv.modifyAttrs(this.mProv.getConfig(), confAttrs, true);
/*      */   }
/*      */   
/*      */   private String namingAttrValue(String name) {
/*  434 */     return name + ".mailuser";
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   private void healthTest()
/*      */     throws Exception
/*      */   {
/*  444 */     System.out.println("Testing health");
/*      */     
/*  446 */     this.mProv.healthCheck();
/*      */   }
/*      */   
/*      */   private com.zimbra.cs.account.Config configTest() throws Exception {
/*  450 */     System.out.println("Testing config");
/*      */     
/*  452 */     com.zimbra.cs.account.Config entry = this.mProv.getConfig();
/*  453 */     assertNotNull(entry);
/*      */     
/*  455 */     return entry;
/*      */   }
/*      */   
/*      */   private String cosTest() throws Exception {
/*  459 */     System.out.println("Testing cos");
/*      */     
/*  461 */     Cos entry = this.mProv.createCos(this.COS_NAME, new HashMap());
/*      */     
/*  463 */     Cos entryGot = this.mProv.get(com.zimbra.common.account.Key.CosBy.id, entry.getId());
/*  464 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/*  465 */     entryGot = this.mProv.get(com.zimbra.common.account.Key.CosBy.name, this.COS_NAME);
/*  466 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/*  467 */     Cos defaultCos = this.mProv.get(com.zimbra.common.account.Key.CosBy.name, "default");
/*  468 */     assertNotNull(defaultCos);
/*      */     
/*  470 */     String destCosName = "cos2-" + this.TEST_ID;
/*  471 */     Cos destCos = this.mProv.copyCos(defaultCos.getId(), destCosName);
/*      */     
/*  473 */     List list = this.mProv.getAllCos();
/*  474 */     TestProvisioningUtil.verifyEntries(list, new NamedEntry[] { defaultCos, entry, destCos }, false);
/*      */     
/*  476 */     this.mProv.renameCos(entry.getId(), this.NEW_NAME);
/*  477 */     this.mProv.renameCos(entry.getId(), this.COS_NAME);
/*      */     
/*  479 */     return entry.getName();
/*      */   }
/*      */   
/*      */   private String[] domainTest() throws Exception {
/*  483 */     System.out.println("Testing domain");
/*      */     
/*  485 */     int numVirtualHosts = 500;
/*      */     
/*  487 */     Map<String, Object> attrs = new HashMap();
/*  488 */     attrs.put("zimbraPreAuthKey", this.PRE_AUTH_KEY);
/*      */     
/*  490 */     Set<String> virtualHosts = new java.util.HashSet();
/*  491 */     for (int i = 0; i < numVirtualHosts; i++) {
/*  492 */       String virtualHostName = "vhost-" + i + "-" + this.TEST_ID + ".com";
/*  493 */       virtualHosts.add(virtualHostName);
/*      */     }
/*  495 */     attrs.put("zimbraVirtualHostname", virtualHosts.toArray(new String[0]));
/*  496 */     Domain entry = this.mProv.createDomain(this.DOMAIN_NAME, attrs);
/*      */     
/*  498 */     Domain entryGot = this.mProv.get(com.zimbra.common.account.Key.DomainBy.id, entry.getId());
/*  499 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/*  500 */     entryGot = this.mProv.get(com.zimbra.common.account.Key.DomainBy.name, this.DOMAIN_NAME);
/*  501 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/*  502 */     for (int i = 0; i < numVirtualHosts; i++) {
/*  503 */       String virtualHostName = "vhost-" + i + "-" + this.TEST_ID + ".com";
/*  504 */       entryGot = this.mProv.get(com.zimbra.common.account.Key.DomainBy.virtualHostname, virtualHostName);
/*  505 */       TestProvisioningUtil.verifySameEntry(entry, entryGot);
/*      */     }
/*      */     
/*  508 */     Domain otherEntry = this.mProv.createDomain(this.OTHER_DOMAIN_NAME, attrs);
/*  509 */     Domain specialCharEntry = this.mProv.createDomain(this.DOMAIN_NAME_SPECIAL_CHARS, attrs);
/*      */     
/*  511 */     List list = this.mProv.getAllDomains();
/*  512 */     TestProvisioningUtil.verifyEntries(list, new NamedEntry[] { entry, otherEntry, specialCharEntry }, false);
/*      */     
/*      */ 
/*  515 */     setDefaultDomain(this.DOMAIN_NAME);
/*      */     
/*  517 */     return new String[] { entry.getName(), otherEntry.getName(), specialCharEntry.getName() };
/*      */   }
/*      */   
/*      */   private void mimeTest() throws Exception {
/*  521 */     System.out.println("Testing mime");
/*      */     
/*  523 */     List<com.zimbra.cs.mime.MimeTypeInfo> mime = this.mProv.getMimeTypes("all");
/*  524 */     assertEquals(1, mime.size());
/*      */   }
/*      */   
/*      */   private com.zimbra.cs.account.Server serverTest() throws Exception {
/*  528 */     System.out.println("Testing server");
/*      */     
/*  530 */     Map<String, Object> serverAttrs = new HashMap();
/*  531 */     com.zimbra.cs.account.Server entry = this.mProv.createServer(this.SERVER_NAME, serverAttrs);
/*      */     
/*  533 */     com.zimbra.cs.account.Server entryGot = this.mProv.get(com.zimbra.common.account.Key.ServerBy.id, entry.getId());
/*  534 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/*  535 */     entryGot = this.mProv.get(com.zimbra.common.account.Key.ServerBy.name, this.SERVER_NAME);
/*  536 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  545 */     com.zimbra.cs.account.Server localServer = this.mProv.getLocalServer();
/*  546 */     assertNotNull(localServer);
/*      */     
/*  548 */     List list = this.mProv.getAllServers();
/*  549 */     TestProvisioningUtil.verifyEntries(list, new NamedEntry[] { localServer, entry }, false);
/*      */     
/*  551 */     list = this.mProv.getAllServers("mailbox");
/*  552 */     TestProvisioningUtil.verifyEntries(list, new NamedEntry[] { localServer }, false);
/*      */     
/*  554 */     return entry;
/*      */   }
/*      */   
/*      */   private com.zimbra.cs.account.Zimlet zimletTest() throws Exception {
/*  558 */     System.out.println("Testing zimlet");
/*      */     
/*  560 */     Map<String, Object> zimletAttrs = new HashMap();
/*  561 */     zimletAttrs.put("zimbraZimletVersion", "1.0");
/*  562 */     com.zimbra.cs.account.Zimlet entry = this.mProv.createZimlet(this.ZIMLET_NAME, zimletAttrs);
/*      */     
/*  564 */     com.zimbra.cs.account.Zimlet entryGot = this.mProv.getZimlet(this.ZIMLET_NAME);
/*  565 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  575 */     return entry;
/*      */   }
/*      */   
/*      */   private void externalAuthTest(Account account, boolean startTLS) throws Exception {
/*  579 */     Domain domain = this.mProv.getDomain(account);
/*  580 */     Map attrsToMod = new HashMap();
/*  581 */     attrsToMod.put("zimbraAuthMech", com.zimbra.cs.account.auth.AuthMechanism.AuthMech.ldap.name());
/*  582 */     attrsToMod.put("zimbraAuthLdapURL", "ldap://" + com.zimbra.common.localconfig.LC.zimbra_server_hostname.value() + ":389");
/*  583 */     attrsToMod.put("zimbraAuthLdapSearchFilter", "(zimbraMailDeliveryAddress=%n)");
/*  584 */     attrsToMod.put("zimbraAuthLdapSearchBindPassword", com.zimbra.common.localconfig.LC.zimbra_ldap_password.value());
/*  585 */     attrsToMod.put("zimbraAuthLdapSearchBindDn", com.zimbra.common.localconfig.LC.zimbra_ldap_userdn.value());
/*      */     
/*  587 */     if (startTLS) {
/*  588 */       attrsToMod.put("zimbraAuthLdapStartTlsEnabled", "TRUE");
/*      */     }
/*  590 */     this.mProv.modifyAttrs(domain, attrsToMod, true);
/*  591 */     this.mProv.authAccount(account, this.PASSWORD, com.zimbra.cs.account.auth.AuthContext.Protocol.test);
/*      */   }
/*      */   
/*      */   private void authTest(Account account) throws Exception {
/*  595 */     System.out.println("Testing auth");
/*      */     
/*      */ 
/*  598 */     this.mProv.authAccount(account, this.PASSWORD, com.zimbra.cs.account.auth.AuthContext.Protocol.test);
/*      */     
/*      */ 
/*  601 */     externalAuthTest(account, false);
/*      */     
/*      */ 
/*      */ 
/*  605 */     Domain domain = this.mProv.getDomain(account);
/*  606 */     Map attrsToMod = new HashMap();
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  613 */     attrsToMod.clear();
/*  614 */     attrsToMod.put("zimbraAuthMech", com.zimbra.cs.account.auth.AuthMechanism.AuthMech.kerberos5.name());
/*  615 */     attrsToMod.put("zimbraAuthKerberos5Realm", "PHOEBE.LOCAL");
/*  616 */     this.mProv.modifyAttrs(domain, attrsToMod, true);
/*      */     
/*      */ 
/*  619 */     attrsToMod.clear();
/*  620 */     attrsToMod.put("zimbraForeignPrincipal", "kerberos5:user1@PHOEBE.LOCAL");
/*  621 */     this.mProv.modifyAttrs(account, attrsToMod, true);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  641 */     attrsToMod.clear();
/*  642 */     String customAuthHandlerName = "test";
/*  643 */     String args = "http://blah.com:123    green \" ocean blue   \"  \"\" yelllow \"\"";
/*  644 */     attrsToMod.put("zimbraAuthMech", com.zimbra.cs.account.auth.AuthMechanism.AuthMech.custom.name() + ":" + customAuthHandlerName + " " + args);
/*  645 */     this.mProv.modifyAttrs(domain, attrsToMod, true);
/*  646 */     com.zimbra.cs.account.auth.ZimbraCustomAuth.register(customAuthHandlerName, new TestCustomAuth(account, this.PASSWORD));
/*  647 */     this.mProv.authAccount(account, this.PASSWORD, com.zimbra.cs.account.auth.AuthContext.Protocol.test);
/*      */     
/*      */     try
/*      */     {
/*  651 */       this.mProv.authAccount(account, this.PASSWORD + "-not", com.zimbra.cs.account.auth.AuthContext.Protocol.test);
/*  652 */       fail("AccountServiceException.AUTH_FAILED not thrown");
/*      */     } catch (ServiceException e) {
/*  654 */       assertEquals("account.AUTH_FAILED", e.getCode());
/*      */     }
/*      */     
/*      */ 
/*  658 */     attrsToMod.put("zimbraAuthMech", com.zimbra.cs.account.auth.AuthMechanism.AuthMech.zimbra.name());
/*  659 */     this.mProv.modifyAttrs(domain, attrsToMod, true);
/*      */     
/*      */ 
/*  662 */     HashMap<String, String> params = new HashMap();
/*  663 */     String authBy = "name";
/*  664 */     long timestamp = System.currentTimeMillis();
/*  665 */     long expires = 0L;
/*  666 */     params.put("account", this.ACCT_EMAIL);
/*  667 */     params.put("by", authBy);
/*  668 */     params.put("timestamp", timestamp + "");
/*  669 */     params.put("expires", expires + "");
/*  670 */     String preAuth = com.zimbra.cs.account.PreAuthKey.computePreAuth(params, this.PRE_AUTH_KEY);
/*  671 */     Map<String, Object> authCtxt = new HashMap();
/*  672 */     authCtxt.put("ocip", "127.0.0.1");
/*  673 */     authCtxt.put("anp", this.ACCT_EMAIL);
/*  674 */     this.mProv.preAuthAccount(account, this.ACCT_EMAIL, authBy, timestamp, 0L, preAuth, authCtxt);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   private Account adminAccountTest()
/*      */     throws Exception
/*      */   {
/*  685 */     System.out.println("Testing admin account");
/*      */     
/*      */ 
/*  688 */     Account entry = this.mProv.get(Key.AccountBy.adminName, this.DEFAULT_LDAP_ADMIN_USER);
/*  689 */     assertNotNull(entry);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  701 */     Map<String, Object> acctAttrs = new HashMap();
/*  702 */     this.mCustomProvTester.addAttr(acctAttrs, this.BASE_DN_PSEUDO_ATTR, this.ACCT_BASE_DN);
/*  703 */     this.mCustomProvTester.addAttr(acctAttrs, this.ACCT_NAMING_ATTR, namingAttrValue(this.ADMIN_USER));
/*  704 */     acctAttrs.put("zimbraIsAdminAccount", "TRUE");
/*  705 */     entry = this.mProv.createAccount(this.ADMIN_EMAIL, this.PASSWORD, acctAttrs);
/*      */     
/*  707 */     Account entryGot = this.mProv.get(Key.AccountBy.name, this.ADMIN_EMAIL);
/*  708 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*  713 */     Account entryGotByuser = this.mProv.get(Key.AccountBy.name, this.ADMIN_USER);
/*  714 */     TestProvisioningUtil.verifySameEntry(entryGot, entryGotByuser);
/*      */     
/*  716 */     if (!Flag.needLdapPaging("getAllAdminAccounts")) {
/*  717 */       List list = this.mProv.getAllAdminAccounts();
/*  718 */       TestProvisioningUtil.verifyEntries(list, new NamedEntry[] { entry }, false);
/*      */     }
/*      */     
/*  721 */     return entry;
/*      */   }
/*      */   
/*      */   private Account[] accountTest(Account adminAcct, Cos cos, Domain domain, Domain otherDomain)
/*      */     throws Exception
/*      */   {
/*  727 */     System.out.println("Testing account");
/*      */     
/*  729 */     String krb5Principal1 = "fp1@FOO.COM";
/*  730 */     String krb5Principal2 = "fp2@BAR.COM";
/*      */     
/*      */ 
/*  733 */     Map<String, Object> acctAttrs = new HashMap();
/*  734 */     this.mCustomProvTester.addAttr(acctAttrs, this.BASE_DN_PSEUDO_ATTR, this.ACCT_BASE_DN);
/*  735 */     this.mCustomProvTester.addAttr(acctAttrs, this.ACCT_NAMING_ATTR, this.ACCT_NAMING_ATTR_VALUE);
/*  736 */     acctAttrs.put("zimbraCOSId", cos.getId());
/*  737 */     acctAttrs.put("zimbraForeignPrincipal", new String[] { "kerberos5:" + krb5Principal1, "kerberos5:" + krb5Principal2 });
/*  738 */     acctAttrs.put("zimbraPrefFromAddress", this.ACCT_EMAIL);
/*  739 */     Account entry = this.mProv.createAccount(this.ACCT_EMAIL, this.PASSWORD, acctAttrs);
/*  740 */     String entryId = entry.getId();
/*  741 */     String acctDn = this.ACCT_NAMING_ATTR + "=" + this.ACCT_NAMING_ATTR_VALUE + "," + this.ACCT_BASE_DN;
/*  742 */     this.mCustomProvTester.verifyDn(entry, acctDn);
/*      */     
/*      */ 
/*  745 */     Map<String, Object> acctAttrsSpecialChars = new HashMap();
/*  746 */     this.mCustomProvTester.addAttr(acctAttrsSpecialChars, this.BASE_DN_PSEUDO_ATTR, this.ACCT_BASE_DN);
/*  747 */     this.mCustomProvTester.addAttr(acctAttrsSpecialChars, this.ACCT_NAMING_ATTR, namingAttrValue(this.ACCT_USER_SPECIAL_CHARS));
/*  748 */     acctAttrs.put("zimbraCOSId", cos.getId());
/*  749 */     Account entrySpecialChars = this.mProv.createAccount(this.ACCT_EMAIL_SPECIAL_CHARS, this.PASSWORD, acctAttrsSpecialChars);
/*  750 */     String acctSpecialCharsDn = this.ACCT_NAMING_ATTR + "=" + namingAttrValue(this.ACCT_USER_SPECIAL_CHARS) + "," + this.ACCT_BASE_DN;
/*  751 */     this.mCustomProvTester.verifyDn(entrySpecialChars, acctSpecialCharsDn);
/*  752 */     Account entryGot = this.mProv.get(Key.AccountBy.name, this.ACCT_EMAIL_SPECIAL_CHARS);
/*  753 */     TestProvisioningUtil.verifySameEntry(entrySpecialChars, entryGot);
/*      */     
/*      */ 
/*  756 */     this.mProv.addAlias(entry, this.ACCT_ALIAS_EMAIL);
/*      */     
/*      */ 
/*  759 */     boolean correct = false;
/*      */     try {
/*  761 */       this.mProv.addAlias(entry, this.ACCT_ALIAS_IN_OTHER_DOMAIN_EMAIL);
/*  762 */       correct = true;
/*      */     } catch (ServiceException e) {
/*  764 */       if (this.mCustomProvTester.isCustom())
/*  765 */         correct = true;
/*      */     }
/*  767 */     assertTrue(correct);
/*      */     
/*      */ 
/*  770 */     entryGot = this.mProv.get(Key.AccountBy.id, entry.getId());
/*  771 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/*      */     
/*      */ 
/*  774 */     entryGot = this.mProv.get(Key.AccountBy.name, this.ACCT_EMAIL);
/*  775 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/*      */     
/*      */ 
/*  778 */     entryGot = this.mProv.get(Key.AccountBy.name, this.ACCT_ALIAS_EMAIL);
/*  779 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/*      */     
/*      */ 
/*  782 */     entryGot = this.mProv.get(Key.AccountBy.name, this.ACCT_ALIAS_IN_OTHER_DOMAIN_EMAIL);
/*  783 */     if (this.mCustomProvTester.isCustom()) {
/*  784 */       assertEquals(null, entryGot);
/*      */     } else {
/*  786 */       TestProvisioningUtil.verifySameEntry(entry, entryGot);
/*      */     }
/*      */     
/*      */ 
/*  790 */     entryGot = this.mProv.get(Key.AccountBy.krb5Principal, krb5Principal1);
/*  791 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/*  792 */     entryGot = this.mProv.get(Key.AccountBy.krb5Principal, krb5Principal2);
/*  793 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/*      */     
/*      */ 
/*  796 */     String krb5PrincipalDup = "fp-dup@FOO.COM";
/*      */     
/*  798 */     String user = "acctx-dup-kerberos";
/*  799 */     acctAttrs.clear();
/*  800 */     this.mCustomProvTester.addAttr(acctAttrs, this.BASE_DN_PSEUDO_ATTR, this.ACCT_BASE_DN);
/*  801 */     this.mCustomProvTester.addAttr(acctAttrs, this.ACCT_NAMING_ATTR, namingAttrValue(user));
/*  802 */     acctAttrs.put("zimbraForeignPrincipal", new String[] { "kerberos5:" + krb5PrincipalDup });
/*  803 */     Account acctX = this.mProv.createAccount(user + "@" + this.DOMAIN_NAME, "test123", acctAttrs);
/*      */     
/*  805 */     user = "accty-dup-kerberos";
/*  806 */     acctAttrs.clear();
/*  807 */     this.mCustomProvTester.addAttr(acctAttrs, this.BASE_DN_PSEUDO_ATTR, this.ACCT_BASE_DN);
/*  808 */     this.mCustomProvTester.addAttr(acctAttrs, this.ACCT_NAMING_ATTR, namingAttrValue(user));
/*  809 */     acctAttrs.put("zimbraForeignPrincipal", new String[] { "kerberos5:" + krb5PrincipalDup });
/*  810 */     Account acctY = this.mProv.createAccount(user + "@" + this.DOMAIN_NAME, "test123", acctAttrs);
/*      */     try {
/*  812 */       this.mProv.get(Key.AccountBy.krb5Principal, krb5PrincipalDup);
/*  813 */       fail();
/*      */     } catch (ServiceException e) {
/*  815 */       assertEquals("account.MULTIPLE_ACCOUNTS_MATCHED", e.getCode());
/*      */     }
/*      */     
/*      */ 
/*  819 */     Map<String, Object> domainAttrs = new HashMap();
/*  820 */     domainAttrs.put("zimbraAuthMech", "kerberos5");
/*  821 */     domainAttrs.put("zimbraAuthKerberos5Realm", "JUNKREALM.COM");
/*  822 */     String krb5DomainName = "krb-test." + this.DOMAIN_NAME;
/*  823 */     Domain krb5TestDomain = this.mProv.createDomain(krb5DomainName, domainAttrs);
/*      */     
/*  825 */     user = "user1";
/*  826 */     acctAttrs.clear();
/*  827 */     this.mCustomProvTester.addAttr(acctAttrs, this.BASE_DN_PSEUDO_ATTR, this.ACCT_BASE_DN);
/*  828 */     this.mCustomProvTester.addAttr(acctAttrs, this.ACCT_NAMING_ATTR, namingAttrValue(user));
/*  829 */     Account krb5TestAcct = this.mProv.createAccount(user + "@" + krb5DomainName, "test123", acctAttrs);
/*  830 */     entryGot = this.mProv.get(Key.AccountBy.krb5Principal, "user1@JUNKREALM.COM");
/*  831 */     TestProvisioningUtil.verifySameEntry(krb5TestAcct, entryGot);
/*      */     
/*  833 */     List list = null;
/*      */     
/*      */ 
/*  836 */     if (!Flag.needLdapPaging("getAllAccounts_domain")) {
/*  837 */       list = this.mProv.getAllAccounts(domain);
/*  838 */       TestProvisioningUtil.verifyEntries(list, new NamedEntry[] { entry, adminAcct, acctX, acctY }, this.mCustomProvTester.verifyAccountCountForDomainBasedSearch());
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*  843 */     if (!Flag.needLdapPaging("getAllAccounts_domain_visitor")) {
/*  844 */       TestVisitor visitor = new TestVisitor(null);
/*  845 */       this.mProv.getAllAccounts(domain, visitor);
/*  846 */       TestProvisioningUtil.verifyEntries(visitor.visited(), new NamedEntry[] { entry, adminAcct, acctX, acctY }, this.mCustomProvTester.verifyAccountCountForDomainBasedSearch());
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*  851 */     if (!Flag.needLdapPaging("getAllAccounts_domain_server_visitor")) {
/*  852 */       TestVisitor visitor = new TestVisitor(null);
/*  853 */       com.zimbra.cs.account.Server server = this.mProv.getLocalServer();
/*  854 */       this.mProv.getAllAccounts(domain, server, visitor);
/*  855 */       TestProvisioningUtil.verifyEntries(visitor.visited(), new NamedEntry[] { entry, adminAcct, acctX, acctY }, this.mCustomProvTester.verifyAccountCountForDomainBasedSearch());
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*  860 */     this.mProv.modifyAccountStatus(entry, "maintenance");
/*  861 */     this.mProv.modifyAccountStatus(entry, "active");
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*  866 */     this.mProv.renameAccount(entryId, this.NEW_EMAIL);
/*  867 */     if (!Flag.needLdapPaging("searchDirectory"))
/*      */     {
/*  869 */       list = searchAccountsInDomain(domain);
/*  870 */       TestProvisioningUtil.verifyEntriesById(list, new String[] { entryId }, false);
/*  871 */       TestProvisioningUtil.verifyEntriesByName(list, new String[] { this.NEW_EMAIL }, false);
/*      */       
/*  873 */       entry = this.mProv.get(Key.AccountBy.id, entryId);
/*  874 */       assertEquals(this.NEW_EMAIL, entry.getAttr("zimbraPrefFromAddress"));
/*      */       
/*  876 */       if (this.mCustomProvTester.isCustom())
/*      */       {
/*  878 */         this.mCustomProvTester.verifyDn(entry, acctDn);
/*      */         
/*      */ 
/*      */ 
/*  882 */         list = searchAliasesInDomain(domain);
/*  883 */         TestProvisioningUtil.verifyEntriesByName(list, new String[] { this.ACCT_ALIAS_EMAIL }, this.mCustomProvTester.verifyAliasCountForDomainBasedSearch());
/*      */       }
/*      */       else {
/*  886 */         list = searchAliasesInDomain(domain);
/*  887 */         TestProvisioningUtil.verifyEntriesByName(list, new String[] { this.ACCT_ALIAS_EMAIL }, true);
/*      */         
/*  889 */         list = searchAliasesInDomain(otherDomain);
/*  890 */         TestProvisioningUtil.verifyEntriesByName(list, new String[] { this.ACCT_ALIAS_IN_OTHER_DOMAIN_EMAIL }, true);
/*      */       }
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*  897 */     correct = false;
/*      */     try {
/*  899 */       this.mProv.renameAccount(entryId, this.NEW_EMAIL_IN_OTHER_DOMAIN);
/*  900 */       correct = true;
/*      */     } catch (ServiceException e) {
/*  902 */       if (this.mCustomProvTester.isCustom())
/*  903 */         correct = true;
/*      */     }
/*  905 */     assertTrue(correct);
/*      */     
/*  907 */     entry = this.mProv.get(Key.AccountBy.id, entryId);
/*      */     
/*  909 */     if ((!this.mCustomProvTester.isCustom()) && 
/*  910 */       (!Flag.needLdapPaging("searchDirectory")))
/*      */     {
/*  912 */       list = searchAccountsInDomain(otherDomain);
/*  913 */       TestProvisioningUtil.verifyEntriesById(list, new String[] { entryId }, true);
/*  914 */       TestProvisioningUtil.verifyEntriesByName(list, new String[] { this.NEW_EMAIL_IN_OTHER_DOMAIN }, true);
/*      */       
/*  916 */       list = searchAliasesInDomain(domain);
/*  917 */       assertEquals(0, list.size());
/*      */       
/*  919 */       list = searchAliasesInDomain(otherDomain);
/*  920 */       TestProvisioningUtil.verifyEntriesByName(list, new String[] { this.ACCT_ALIAS_AFTER_ACCOUNT_RENAME_TO_OTHER_DMAIN_EMAIL, this.ACCT_ALIAS_IN_OTHER_DOMAIN_EMAIL }, true);
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  928 */     this.mProv.renameAccount(entryId, this.ACCT_EMAIL);
/*  929 */     if (!Flag.needLdapPaging("searchDirectory"))
/*      */     {
/*  931 */       list = searchAccountsInDomain(domain);
/*  932 */       TestProvisioningUtil.verifyEntriesById(list, new String[] { entryId }, false);
/*  933 */       TestProvisioningUtil.verifyEntriesByName(list, new String[] { this.ACCT_EMAIL }, false);
/*      */       
/*  935 */       entry = this.mProv.get(Key.AccountBy.id, entryId);
/*      */       
/*  937 */       if (this.mCustomProvTester.isCustom()) {
/*  938 */         list = searchAliasesInDomain(domain);
/*  939 */         TestProvisioningUtil.verifyEntriesByName(list, new String[] { this.ACCT_ALIAS_EMAIL }, this.mCustomProvTester.verifyAliasCountForDomainBasedSearch());
/*      */       }
/*      */       else
/*      */       {
/*  943 */         list = searchAliasesInDomain(otherDomain);
/*  944 */         assertEquals(0, list.size());
/*  945 */         list = searchAliasesInDomain(domain);
/*  946 */         TestProvisioningUtil.verifyEntriesByName(list, new String[] { this.ACCT_ALIAS_EMAIL, this.ACCT_ALIAS_IN_OTHER_DOMAIN_AFTER_ACCOUNT_RENAME_TO_ORIG_DOMAIN_EMAIL }, true);
/*      */       }
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*  953 */     this.mProv.removeAlias(entry, this.ACCT_ALIAS_EMAIL);
/*      */     
/*  955 */     if (!this.mCustomProvTester.isCustom()) {
/*  956 */       this.mProv.removeAlias(entry, this.ACCT_ALIAS_IN_OTHER_DOMAIN_AFTER_ACCOUNT_RENAME_TO_ORIG_DOMAIN_EMAIL);
/*      */     }
/*  958 */     if (!Flag.needLdapPaging("searchDirectory"))
/*      */     {
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  965 */       list = searchAliasesInDomain(domain);
/*  966 */       assertEquals(0, list.size());
/*  967 */       list = searchAliasesInDomain(otherDomain);
/*  968 */       assertEquals(0, list.size());
/*      */     }
/*      */     
/*      */ 
/*  972 */     entry = this.mProv.get(Key.AccountBy.id, entryId);
/*  973 */     this.mProv.setCOS(entry, cos);
/*      */     
/*  975 */     return new Account[] { entry, entrySpecialChars, acctX, acctY };
/*      */   }
/*      */   
/*      */   private void passwordTest(Account account) throws Exception {
/*  979 */     System.out.println("Testing password");
/*      */     
/*  981 */     this.mProv.changePassword(account, this.PASSWORD, this.PASSWORD);
/*  982 */     this.mProv.checkPasswordStrength(account, this.PASSWORD);
/*  983 */     this.mProv.setPassword(account, this.PASSWORD);
/*      */   }
/*      */   
/*      */   private void doLocaleTest(Account acct, String locale) throws Exception {
/*  987 */     Map<String, Object> attrs = new HashMap();
/*  988 */     attrs.put("zimbraPrefLocale", locale);
/*  989 */     this.mSoapProv.modifyAttrs(acct, attrs, true);
/*      */     
/*  991 */     String provLocale = this.mSoapProv.getLocale(acct).toString();
/*  992 */     assertEquals(locale, provLocale);
/*      */     
/*  994 */     String entryLocale = acct.getLocale().toString();
/*  995 */     assertEquals(locale, entryLocale);
/*      */   }
/*      */   
/*      */   private void localeTest() throws Exception {
/*  999 */     System.out.println("Testing locale");
/*      */     
/* 1001 */     Account acct = this.mSoapProv.get(Key.AccountBy.name, this.ACCT_EMAIL);
/* 1002 */     assertNotNull(acct);
/*      */     
/* 1004 */     doLocaleTest(acct, "xxx");
/* 1005 */     doLocaleTest(acct, "yyy");
/* 1006 */     doLocaleTest(acct, "zzz");
/*      */   }
/*      */   
/*      */   private com.zimbra.cs.account.CalendarResource calendarResourceTest(Cos cos, Domain domain) throws Exception
/*      */   {
/* 1011 */     System.out.println("Testing calendar resource");
/*      */     
/* 1013 */     Map<String, Object> crAttrs = new HashMap();
/* 1014 */     this.mCustomProvTester.addAttr(crAttrs, this.BASE_DN_PSEUDO_ATTR, this.ACCT_BASE_DN);
/* 1015 */     this.mCustomProvTester.addAttr(crAttrs, this.ACCT_NAMING_ATTR, namingAttrValue(this.CR_USER));
/* 1016 */     crAttrs.put("displayName", this.CR_USER);
/* 1017 */     crAttrs.put("zimbraCalResType", "Equipment");
/* 1018 */     crAttrs.put("zimbraCOSId", cos.getId());
/* 1019 */     com.zimbra.cs.account.CalendarResource entry = this.mProv.createCalendarResource(this.CR_EMAIL, this.PASSWORD, crAttrs);
/* 1020 */     this.mProv.addAlias(entry, this.CR_ALIAS_EMAIL);
/*      */     
/* 1022 */     com.zimbra.cs.account.CalendarResource entryGot = this.mProv.get(com.zimbra.common.account.Key.CalendarResourceBy.id, entry.getId());
/* 1023 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/* 1024 */     entryGot = this.mProv.get(com.zimbra.common.account.Key.CalendarResourceBy.name, this.CR_EMAIL);
/* 1025 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/* 1026 */     entryGot = this.mProv.get(com.zimbra.common.account.Key.CalendarResourceBy.name, this.CR_ALIAS_EMAIL);
/* 1027 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/*      */     
/* 1029 */     List list = null;
/*      */     
/* 1031 */     if (!Flag.needLdapPaging("getAllCalendarResources_domain")) {
/* 1032 */       list = this.mProv.getAllCalendarResources(domain);
/* 1033 */       TestProvisioningUtil.verifyEntries(list, new NamedEntry[] { entry }, this.mCustomProvTester.verifyAccountCountForDomainBasedSearch());
/*      */     }
/*      */     
/* 1036 */     if (!Flag.needLdapPaging("getAllCalendarResources_domain_visitor")) {
/* 1037 */       TestVisitor visitor = new TestVisitor(null);
/* 1038 */       this.mProv.getAllCalendarResources(domain, visitor);
/* 1039 */       TestProvisioningUtil.verifyEntries(visitor.visited(), new NamedEntry[] { entry }, this.mCustomProvTester.verifyAccountCountForDomainBasedSearch());
/*      */     }
/*      */     
/* 1042 */     this.mProv.renameCalendarResource(entry.getId(), this.NEW_EMAIL);
/* 1043 */     this.mProv.renameCalendarResource(entry.getId(), this.CR_EMAIL);
/*      */     
/* 1045 */     return entry;
/*      */   }
/*      */   
/*      */   private DistributionList[] distributionListTest(Domain domain) throws Exception
/*      */   {
/* 1050 */     System.out.println("Testing distribution list");
/*      */     
/* 1052 */     Map<String, Object> dlAttrs = new HashMap();
/* 1053 */     this.mCustomProvTester.addAttr(dlAttrs, this.BASE_DN_PSEUDO_ATTR, this.ACCT_BASE_DN);
/* 1054 */     this.mCustomProvTester.addAttr(dlAttrs, this.ACCT_NAMING_ATTR, namingAttrValue(this.DL_USER));
/* 1055 */     DistributionList entry = this.mProv.createDistributionList(this.DL_EMAIL, dlAttrs);
/*      */     
/* 1057 */     this.mProv.addAlias(entry, this.DL_ALIAS_EMAIL);
/*      */     
/* 1059 */     DistributionList entryGot = this.mProv.get(com.zimbra.common.account.Key.DistributionListBy.id, entry.getId());
/* 1060 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/* 1061 */     entryGot = this.mProv.get(com.zimbra.common.account.Key.DistributionListBy.name, this.DL_EMAIL);
/* 1062 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/* 1063 */     entryGot = this.mProv.get(com.zimbra.common.account.Key.DistributionListBy.name, this.DL_ALIAS_EMAIL);
/* 1064 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/*      */     
/* 1066 */     Map<String, Object> dlNestedAttrs = new HashMap();
/* 1067 */     this.mCustomProvTester.addAttr(dlNestedAttrs, this.BASE_DN_PSEUDO_ATTR, this.ACCT_BASE_DN);
/* 1068 */     this.mCustomProvTester.addAttr(dlNestedAttrs, this.ACCT_NAMING_ATTR, namingAttrValue(this.DL_NESTED_USER));
/* 1069 */     DistributionList dlNested = this.mProv.createDistributionList(this.DL_NESTED_EMAIL, dlNestedAttrs);
/* 1070 */     this.mProv.addAlias(dlNested, this.DL_NESTED_ALIAS_EMAIL);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1077 */     String curDefaultDomain = this.mProv.getConfig().getAttr("zimbraDefaultDomainName");
/* 1078 */     if (this.mCustomProvTester.isCustom())
/* 1079 */       setDefaultDomain(this.DOMAIN_NAME_SPECIAL_CHARS);
/* 1080 */     Map<String, Object> dlAttrsSpecialChars = new HashMap();
/* 1081 */     this.mCustomProvTester.addAttr(dlAttrsSpecialChars, this.BASE_DN_PSEUDO_ATTR, this.ACCT_BASE_DN);
/* 1082 */     this.mCustomProvTester.addAttr(dlAttrsSpecialChars, this.ACCT_NAMING_ATTR, namingAttrValue(this.DL_USER_SPECIAL_CHARS));
/* 1083 */     DistributionList dlSpecilaChars = this.mProv.createDistributionList(this.DL_EMAIL_SPECIAL_CHARS, dlAttrsSpecialChars);
/* 1084 */     entryGot = this.mProv.get(com.zimbra.common.account.Key.DistributionListBy.name, this.DL_EMAIL_SPECIAL_CHARS);
/* 1085 */     TestProvisioningUtil.verifySameEntry(dlSpecilaChars, entryGot);
/*      */     
/* 1087 */     if (this.mCustomProvTester.isCustom()) {
/* 1088 */       setDefaultDomain(curDefaultDomain);
/*      */     }
/* 1090 */     this.mProv.addMembers(entry, new String[] { this.DL_NESTED_EMAIL });
/* 1091 */     this.mProv.addMembers(dlNested, new String[] { this.ACCT_EMAIL });
/*      */     
/* 1093 */     List list = null;
/*      */     
/* 1095 */     if (!Flag.needLdapPaging("getAllDistributionLists")) {
/* 1096 */       list = this.mProv.getAllDistributionLists(domain);
/* 1097 */       TestProvisioningUtil.verifyEntries(list, new NamedEntry[] { entry, dlNested }, this.mCustomProvTester.verifyDLCountForDomainBasedSearch());
/*      */     }
/*      */     
/* 1100 */     Account account = this.mProv.get(Key.AccountBy.name, this.ACCT_EMAIL);
/* 1101 */     Set<String> set = null;
/*      */     
/* 1103 */     if (!Flag.needLdapPaging("getDistributionLists_account")) {
/* 1104 */       set = this.mProv.getDistributionLists(account);
/* 1105 */       assertEquals(2, set.size());
/* 1106 */       assertTrue(set.contains(entry.getId()));
/* 1107 */       assertTrue(set.contains(dlNested.getId()));
/*      */     }
/*      */     
/* 1110 */     if (!Flag.needLdapPaging("getDistributionLists_account_directonly_via")) {
/* 1111 */       Map<String, String> via = new HashMap();
/* 1112 */       list = this.mProv.getDistributionLists(account, false, via);
/* 1113 */       TestProvisioningUtil.verifyEntries(list, new NamedEntry[] { entry, dlNested }, true);
/* 1114 */       assertEquals(1, via.size());
/* 1115 */       assertEquals(dlNested.getName(), (String)via.get(entry.getName()));
/*      */     }
/*      */     
/* 1118 */     if (!Flag.needLdapPaging("getDistributionLists_account_directonly_via")) {
/* 1119 */       list = this.mProv.getDistributionLists(account, true, null);
/* 1120 */       TestProvisioningUtil.verifyEntries(list, new NamedEntry[] { dlNested }, true);
/*      */     }
/*      */     
/* 1123 */     if (!Flag.needLdapPaging("inDistributionList")) {
/* 1124 */       boolean inList = this.mProv.inDistributionList(account, entry.getId());
/* 1125 */       assertTrue(inList);
/*      */     }
/*      */     
/* 1128 */     this.mProv.removeAlias(entry, this.DL_ALIAS_EMAIL);
/*      */     
/* 1130 */     this.mProv.removeMembers(entry, new String[] { dlNested.getName() });
/*      */     
/* 1132 */     this.mProv.renameDistributionList(entry.getId(), this.NEW_EMAIL);
/* 1133 */     entryGot = this.mProv.get(com.zimbra.common.account.Key.DistributionListBy.name, this.NEW_EMAIL);
/* 1134 */     TestProvisioningUtil.verifySameId(entry, entryGot);
/* 1135 */     if (!Flag.needLdapPaging("getAllDistributionLists")) {
/* 1136 */       list = this.mProv.getAllDistributionLists(domain);
/* 1137 */       TestProvisioningUtil.verifyEntriesByName(list, new String[] { this.NEW_EMAIL, this.DL_NESTED_EMAIL }, this.mCustomProvTester.verifyDLCountForDomainBasedSearch());
/*      */     }
/*      */     
/*      */ 
/* 1141 */     entry = this.mProv.get(com.zimbra.common.account.Key.DistributionListBy.name, this.NEW_EMAIL);
/*      */     
/*      */ 
/* 1144 */     this.mProv.renameDistributionList(entry.getId(), this.DL_EMAIL);
/* 1145 */     entryGot = this.mProv.get(com.zimbra.common.account.Key.DistributionListBy.name, this.DL_EMAIL);
/* 1146 */     TestProvisioningUtil.verifySameId(entry, entryGot);
/* 1147 */     if (!Flag.needLdapPaging("getAllDistributionLists")) {
/* 1148 */       list = this.mProv.getAllDistributionLists(domain);
/* 1149 */       TestProvisioningUtil.verifyEntriesByName(list, new String[] { this.DL_EMAIL, this.DL_NESTED_EMAIL }, this.mCustomProvTester.verifyDLCountForDomainBasedSearch());
/*      */     }
/*      */     
/* 1152 */     return new DistributionList[] { entry, dlNested, dlSpecilaChars };
/*      */   }
/*      */   
/*      */   private com.zimbra.cs.account.DataSource dataSourceTest(Account account) throws Exception {
/* 1156 */     System.out.println("Testing data source");
/*      */     
/* 1158 */     Map<String, Object> dsAttrs = new HashMap();
/* 1159 */     dsAttrs.put("zimbraDataSourceEnabled", "TRUE");
/* 1160 */     dsAttrs.put("zimbraDataSourceConnectionType", "ssl");
/* 1161 */     dsAttrs.put("zimbraDataSourceFolderId", "inbox");
/* 1162 */     dsAttrs.put("zimbraDataSourceHost", "pop.google.com");
/* 1163 */     dsAttrs.put("zimbraDataSourceLeaveOnServer", "TRUE");
/* 1164 */     dsAttrs.put("zimbraDataSourcePassword", this.PASSWORD);
/* 1165 */     dsAttrs.put("zimbraDataSourcePort", "9999");
/* 1166 */     dsAttrs.put("zimbraDataSourceUsername", "mickymouse");
/* 1167 */     dsAttrs.put("zimbraDataSourceEmailAddress", "micky@google.com");
/* 1168 */     dsAttrs.put("zimbraPrefDefaultSignatureId", com.zimbra.cs.ldap.LdapUtil.generateUUID());
/* 1169 */     dsAttrs.put("zimbraPrefFromDisplay", "Micky Mouse");
/* 1170 */     dsAttrs.put("zimbraPrefReplyToAddress", "goofy@yahoo.com");
/* 1171 */     dsAttrs.put("zimbraPrefReplyToDisplay", "Micky");
/*      */     
/* 1173 */     com.zimbra.cs.account.DataSource entry = this.mProv.createDataSource(account, com.zimbra.soap.admin.type.DataSourceType.pop3, this.DATA_SOURCE_NAME, dsAttrs);
/*      */     
/* 1175 */     com.zimbra.cs.account.DataSource entryGot = this.mProv.get(account, com.zimbra.common.account.Key.DataSourceBy.id, entry.getId());
/* 1176 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/* 1177 */     entryGot = this.mProv.get(account, com.zimbra.common.account.Key.DataSourceBy.name, this.DATA_SOURCE_NAME);
/* 1178 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/*      */     
/* 1180 */     List list = this.mProv.getAllDataSources(account);
/* 1181 */     TestProvisioningUtil.verifyEntries(list, new NamedEntry[] { entry }, true);
/*      */     
/* 1183 */     Map attrsToMod = new HashMap();
/* 1184 */     attrsToMod.put("zimbraDataSourcePollingInterval", "100");
/* 1185 */     this.mProv.modifyDataSource(account, entry.getId(), attrsToMod);
/*      */     
/* 1187 */     return entry;
/*      */   }
/*      */   
/*      */   private com.zimbra.cs.account.Identity identityTest(Account account) throws Exception {
/* 1191 */     System.out.println("Testing identity");
/*      */     
/* 1193 */     Map<String, Object> identityAttrs = new HashMap();
/* 1194 */     identityAttrs.put("zimbraPrefDefaultSignatureId", com.zimbra.cs.ldap.LdapUtil.generateUUID());
/* 1195 */     identityAttrs.put("zimbraPrefFromAddress", "micky.mouse@zimbra,com");
/* 1196 */     identityAttrs.put("zimbraPrefFromDisplay", "Micky Mouse");
/* 1197 */     identityAttrs.put("zimbraPrefReplyToEnabled", "TRUE");
/* 1198 */     identityAttrs.put("zimbraPrefReplyToAddress", "goofy@yahoo.com");
/* 1199 */     identityAttrs.put("zimbraPrefReplyToDisplay", "Micky");
/* 1200 */     com.zimbra.cs.account.Identity entry = this.mProv.createIdentity(account, this.IDENTITY_NAME, identityAttrs);
/*      */     
/* 1202 */     com.zimbra.cs.account.Identity entryGot = this.mProv.get(account, com.zimbra.common.account.Key.IdentityBy.id, entry.getId());
/* 1203 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/* 1204 */     entryGot = this.mProv.get(account, com.zimbra.common.account.Key.IdentityBy.name, this.IDENTITY_NAME);
/* 1205 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/* 1206 */     com.zimbra.cs.account.Identity defaultIdentity = this.mProv.get(account, com.zimbra.common.account.Key.IdentityBy.name, "DEFAULT");
/* 1207 */     TestProvisioningUtil.verifySameId(account, defaultIdentity);
/* 1208 */     assertEquals("DEFAULT", defaultIdentity.getName());
/*      */     
/* 1210 */     List list = this.mProv.getAllIdentities(account);
/* 1211 */     TestProvisioningUtil.verifyEntries(list, new NamedEntry[] { defaultIdentity, entry }, true);
/*      */     
/*      */ 
/* 1214 */     Map attrsToMod = new HashMap();
/* 1215 */     attrsToMod.put("zimbraPrefReplyToDisplay", "MM");
/* 1216 */     this.mProv.modifyIdentity(account, this.IDENTITY_NAME, attrsToMod);
/*      */     
/*      */ 
/* 1219 */     String newName = "identity-new-name";
/* 1220 */     attrsToMod.clear();
/* 1221 */     attrsToMod.put("zimbraPrefIdentityName", newName);
/* 1222 */     this.mProv.modifyIdentity(account, this.IDENTITY_NAME, attrsToMod);
/*      */     
/*      */ 
/* 1225 */     entryGot = this.mProv.get(account, com.zimbra.common.account.Key.IdentityBy.name, newName);
/* 1226 */     entry = this.mProv.get(account, com.zimbra.common.account.Key.IdentityBy.id, entry.getId());
/* 1227 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/*      */     
/*      */ 
/* 1230 */     attrsToMod.clear();
/* 1231 */     attrsToMod.put("zimbraPrefIdentityName", this.IDENTITY_NAME);
/* 1232 */     this.mProv.modifyIdentity(account, newName, attrsToMod);
/*      */     
/*      */ 
/* 1235 */     entry = this.mProv.get(account, com.zimbra.common.account.Key.IdentityBy.id, entry.getId());
/*      */     
/* 1237 */     return entry;
/*      */   }
/*      */   
/*      */   private void signatureTest(Account account) throws Exception {
/* 1241 */     System.out.println("Testing signature");
/*      */     
/*      */ 
/* 1244 */     Map<String, Object> signatureAttrs = new HashMap();
/* 1245 */     signatureAttrs.put("zimbraPrefMailSignature", this.SIGNATURE_VALUE);
/* 1246 */     Signature entry = this.mProv.createSignature(account, this.SIGNATURE_NAME, signatureAttrs);
/*      */     
/*      */ 
/* 1249 */     Signature entryGot = this.mProv.get(account, com.zimbra.common.account.Key.SignatureBy.id, entry.getId());
/* 1250 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/*      */     
/*      */ 
/* 1253 */     entryGot = this.mProv.get(account, com.zimbra.common.account.Key.SignatureBy.name, this.SIGNATURE_NAME);
/* 1254 */     TestProvisioningUtil.verifySameEntry(entry, entryGot);
/*      */     
/*      */ 
/* 1257 */     List list = this.mProv.getAllSignatures(account);
/* 1258 */     TestProvisioningUtil.verifyEntries(list, new NamedEntry[] { entry }, true);
/*      */     
/*      */ 
/* 1261 */     String defaultSigId = account.getAttr("zimbraPrefDefaultSignatureId");
/* 1262 */     assertEquals(entry.getId(), defaultSigId);
/*      */     
/*      */ 
/* 1265 */     Map attrsToMod = new HashMap();
/* 1266 */     attrsToMod.put("zimbraPrefMailSignature", this.SIGNATURE_VALUE_MODIFIED);
/* 1267 */     this.mProv.modifySignature(account, entry.getId(), attrsToMod);
/*      */     
/*      */ 
/* 1270 */     entryGot = this.mProv.get(account, com.zimbra.common.account.Key.SignatureBy.id, entry.getId());
/* 1271 */     assertEquals(this.SIGNATURE_VALUE_MODIFIED, entryGot.getAttr("zimbraPrefMailSignature"));
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1287 */     String secondSigName = "second-sig";
/* 1288 */     signatureAttrs.clear();
/* 1289 */     Signature secondEntry = this.mProv.createSignature(account, secondSigName, signatureAttrs);
/* 1290 */     Map<String, Object> acctAttrs = new HashMap();
/* 1291 */     acctAttrs.put("zimbraPrefDefaultSignatureId", secondEntry.getId());
/* 1292 */     this.mProv.modifyAttrs(account, acctAttrs);
/*      */     
/*      */ 
/* 1295 */     this.mProv.deleteSignature(account, entry.getId());
/*      */     
/*      */ 
/* 1298 */     String secondSigNameNew = "second-sig-new-name";
/* 1299 */     signatureAttrs.clear();
/* 1300 */     signatureAttrs.put("zimbraSignatureName", secondSigNameNew);
/* 1301 */     this.mProv.modifySignature(account, secondEntry.getId(), signatureAttrs);
/* 1302 */     defaultSigId = account.getAttr("zimbraPrefDefaultSignatureId");
/* 1303 */     assertEquals(secondEntry.getId(), defaultSigId);
/*      */     
/* 1305 */     secondEntry = this.mProv.get(account, com.zimbra.common.account.Key.SignatureBy.name, secondSigNameNew);
/*      */     
/*      */ 
/* 1308 */     String thirdSigName = "third-sig";
/* 1309 */     signatureAttrs.clear();
/* 1310 */     Signature thirdEntry = this.mProv.createSignature(account, thirdSigName, signatureAttrs);
/* 1311 */     String acctSigName = account.getAttr("zimbraSignatureName");
/* 1312 */     assertEquals(thirdSigName, acctSigName);
/*      */     
/* 1314 */     list = this.mProv.getAllSignatures(account);
/* 1315 */     TestProvisioningUtil.verifyEntries(list, new NamedEntry[] { secondEntry, thirdEntry }, true);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1321 */     this.mProv.deleteSignature(account, thirdEntry.getId());
/*      */     
/*      */ 
/* 1324 */     String aSigValueOnAccount = "a signature value on account";
/* 1325 */     String accountSigName = account.getName();
/* 1326 */     acctAttrs.clear();
/* 1327 */     acctAttrs.put("zimbraPrefMailSignature", aSigValueOnAccount);
/* 1328 */     this.mProv.modifyAttrs(account, acctAttrs);
/*      */     
/*      */ 
/* 1331 */     Signature acctSig = this.mProv.get(account, com.zimbra.common.account.Key.SignatureBy.name, accountSigName);
/* 1332 */     assertEquals(account.getName(), acctSig.getName());
/* 1333 */     assertNotSame(account.getId(), acctSig.getId());
/* 1334 */     assertEquals(acctSig.getAttr("zimbraPrefMailSignature"), aSigValueOnAccount);
/*      */     
/*      */ 
/* 1337 */     acctSig = this.mProv.get(account, com.zimbra.common.account.Key.SignatureBy.id, acctSig.getId());
/* 1338 */     assertNotSame(account.getId(), acctSig.getId());
/* 1339 */     assertEquals(acctSig.getAttr("zimbraPrefMailSignature"), aSigValueOnAccount);
/*      */     
/*      */ 
/* 1342 */     list = this.mProv.getAllSignatures(account);
/* 1343 */     TestProvisioningUtil.verifyEntries(list, new NamedEntry[] { acctSig, secondEntry }, true);
/*      */     
/*      */ 
/* 1346 */     this.mProv.deleteSignature(account, acctSig.getId());
/*      */     
/*      */ 
/* 1349 */     acctAttrs.clear();
/* 1350 */     acctAttrs.put("zimbraPrefMailSignature", aSigValueOnAccount);
/* 1351 */     this.mProv.modifyAttrs(account, acctAttrs);
/*      */     
/*      */ 
/* 1354 */     acctSig = this.mProv.get(account, com.zimbra.common.account.Key.SignatureBy.name, accountSigName);
/*      */     
/* 1356 */     acctAttrs.clear();
/* 1357 */     acctAttrs.put("zimbraPrefDefaultSignatureId", acctSig.getId());
/* 1358 */     this.mProv.modifyAttrs(account, acctAttrs);
/* 1359 */     assertEquals(acctSig.getAttr("zimbraPrefMailSignature"), aSigValueOnAccount);
/*      */     
/*      */ 
/* 1362 */     String accountSigNameNew = "account-sig-new-name";
/* 1363 */     signatureAttrs.clear();
/* 1364 */     signatureAttrs.put("zimbraSignatureName", accountSigNameNew);
/* 1365 */     this.mProv.modifySignature(account, acctSig.getId(), signatureAttrs);
/*      */     
/*      */ 
/* 1368 */     Signature renamedAcctSig = this.mProv.get(account, com.zimbra.common.account.Key.SignatureBy.name, accountSigNameNew);
/* 1369 */     assertEquals(renamedAcctSig.getId(), acctSig.getId());
/*      */     
/*      */ 
/* 1372 */     defaultSigId = account.getAttr("zimbraPrefDefaultSignatureId");
/* 1373 */     assertEquals(acctSig.getId(), defaultSigId);
/*      */     
/*      */ 
/* 1376 */     acctAttrs.clear();
/* 1377 */     acctAttrs.put("zimbraPrefDefaultSignatureId", secondEntry.getName());
/* 1378 */     this.mProv.modifyAttrs(account, acctAttrs);
/*      */     
/*      */ 
/* 1381 */     this.mProv.deleteSignature(account, renamedAcctSig.getId());
/*      */   }
/*      */   
/*      */   private void entryTest(NamedEntry entry) throws Exception
/*      */   {
/* 1386 */     System.out.println("Testing entry");
/*      */     
/* 1388 */     Map attrsToMod = new HashMap();
/* 1389 */     attrsToMod.put("zimbraId", "junk");
/*      */     try
/*      */     {
/* 1392 */       this.mProv.modifyAttrs(entry, attrsToMod, true);
/* 1393 */       fail("ServiceException.INVALID_REQUEST not thrown");
/*      */     } catch (ServiceException e) {
/* 1395 */       assertEquals("service.INVALID_REQUEST", e.getCode());
/*      */     }
/*      */     
/* 1398 */     attrsToMod.clear();
/* 1399 */     attrsToMod.put("displayName", this.ACCT_FULL_NAME);
/* 1400 */     this.mProv.modifyAttrs(entry, attrsToMod, true, true);
/*      */     
/*      */ 
/* 1403 */     if (this.mLdapProv != null) {
/* 1404 */       String namingAttr = this.mLdapProv.getDIT().getNamingRdnAttr(entry);
/* 1405 */       if (!namingAttr.equals("cn")) {
/* 1406 */         String cnValue = entry.getAttr("cn");
/* 1407 */         assertEquals(this.ACCT_FULL_NAME, cnValue);
/*      */       }
/*      */     }
/*      */     
/* 1411 */     this.mProv.reload(entry);
/*      */   }
/*      */   
/*      */   private void externalGalTest(Domain domain, boolean startTLS) throws Exception {
/* 1415 */     Map<String, String> attrs = new HashMap();
/* 1416 */     attrs.put("zimbraGalMode", com.zimbra.cs.account.auth.AuthMechanism.AuthMech.ldap.name());
/* 1417 */     attrs.put("zimbraGalLdapURL", "ldap://" + com.zimbra.common.localconfig.LC.zimbra_server_hostname.value() + ":389");
/*      */     
/* 1419 */     attrs.put("zimbraGalLdapBindDn", com.zimbra.common.localconfig.LC.zimbra_ldap_userdn.value());
/* 1420 */     attrs.put("zimbraGalLdapBindPassword", "zimbra");
/* 1421 */     attrs.put("zimbraGalLdapFilter", "(mail=*%s*)");
/*      */     
/*      */ 
/* 1424 */     attrs.put("zimbraGalLdapKerberos5Principal", "ldap/phoebe.local@PHOEBE.LOCAL");
/* 1425 */     attrs.put("zimbraGalLdapKerberos5Keytab", "/etc/krb5.keytab");
/*      */     
/* 1427 */     if (startTLS) {
/* 1428 */       attrs.put("zimbraGalLdapStartTlsEnabled", "TRUE");
/* 1429 */       attrs.put("zimbraGalSyncLdapStartTlsEnabled", "TRUE");
/*      */     }
/*      */     
/* 1432 */     this.mProv.modifyAttrs(domain, attrs, true);
/* 1433 */     com.zimbra.cs.account.Provisioning.SearchGalResult galResult = this.mProv.searchGal(domain, this.ACCT_EMAIL, com.zimbra.soap.type.GalSearchType.all, 0, null);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1439 */     List<com.zimbra.cs.account.GalContact> matches = galResult.getMatches();
/* 1440 */     assertEquals(1, galResult.getNumMatches());
/* 1441 */     assertEquals(this.ACCT_FULL_NAME, ((com.zimbra.cs.account.GalContact)matches.get(0)).getAttrs().get("fullName"));
/*      */   }
/*      */   
/*      */   private void galTest(Domain domain) throws Exception {
/* 1445 */     System.out.println("Testing gal");
/*      */     
/* 1447 */     String query = this.ACCT_USER;
/* 1448 */     Account acct = this.mProv.get(Key.AccountBy.name, this.ACCT_EMAIL);
/*      */     
/*      */ 
/* 1451 */     com.zimbra.cs.account.Provisioning.SearchGalResult galResult = this.mProv.autoCompleteGal(domain, query, com.zimbra.soap.type.GalSearchType.all, 100, null);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1457 */     List<com.zimbra.cs.account.GalContact> matches = galResult.getMatches();
/* 1458 */     assertEquals(1, galResult.getNumMatches());
/* 1459 */     assertEquals(this.ACCT_FULL_NAME, ((com.zimbra.cs.account.GalContact)matches.get(0)).getAttrs().get("fullName"));
/*      */     
/*      */ 
/* 1462 */     galResult = this.mProv.searchGal(domain, query, com.zimbra.soap.type.GalSearchType.all, 0, null);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1467 */     matches = galResult.getMatches();
/* 1468 */     assertEquals(1, galResult.getNumMatches());
/* 1469 */     assertEquals(this.ACCT_FULL_NAME, ((com.zimbra.cs.account.GalContact)matches.get(0)).getAttrs().get("fullName"));
/*      */     
/*      */ 
/* 1472 */     externalGalTest(domain, false);
/*      */   }
/*      */   
/*      */ 
/*      */   private void searchTest(Domain domain)
/*      */     throws Exception
/*      */   {
/* 1479 */     System.out.println("Testing search");
/*      */     
/* 1481 */     Account acct = this.mProv.get(Key.AccountBy.name, this.ACCT_EMAIL);
/*      */     
/* 1483 */     String query = "(zimbraMailDeliveryAddress=" + this.ACCT_EMAIL + ")";
/* 1484 */     List list = null;
/*      */     
/* 1486 */     if (!Flag.needLdapPaging("searchDirectory")) {
/* 1487 */       SearchDirectoryOptions options = new SearchDirectoryOptions();
/* 1488 */       options.setDomain(domain);
/* 1489 */       options.setFilterString(com.zimbra.cs.ldap.ZLdapFilterFactory.FilterId.UNITTEST, query);
/* 1490 */       options.setTypes(new SearchDirectoryOptions.ObjectType[] { SearchDirectoryOptions.ObjectType.accounts });
/* 1491 */       list = this.mProv.searchDirectory(options);
/* 1492 */       TestProvisioningUtil.verifyEntries(list, new NamedEntry[] { acct }, true);
/*      */     }
/*      */   }
/*      */   
/*      */   private Domain aliasTest() throws Exception {
/* 1497 */     System.out.println("Testing alias");
/*      */     
/*      */ 
/* 1500 */     String domainName = "alias-test." + this.DOMAIN_NAME;
/* 1501 */     Domain domain = this.mProv.createDomain(domainName, new HashMap());
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1518 */     return domain;
/*      */   }
/*      */   
/*      */   private void familyTest() throws Exception {
/* 1522 */     System.out.println("Testing family");
/*      */     
/* 1524 */     Set<String> visibleCids = new java.util.HashSet();
/* 1525 */     Set<String> invisibleCids = new java.util.HashSet();
/* 1526 */     Set<String> cids = new java.util.HashSet();
/* 1527 */     Map attrs = new HashMap();
/*      */     
/*      */ 
/* 1530 */     for (int i = 0; i < 5; i++) {
/* 1531 */       attrs.clear();
/* 1532 */       String childNameLocal = "v-child-" + i;
/* 1533 */       String childName = childNameLocal + "@" + this.DOMAIN_NAME;
/* 1534 */       this.mCustomProvTester.addAttr(attrs, this.BASE_DN_PSEUDO_ATTR, this.ACCT_BASE_DN);
/* 1535 */       this.mCustomProvTester.addAttr(attrs, this.ACCT_NAMING_ATTR, namingAttrValue(childNameLocal));
/* 1536 */       Account acct = this.mProv.createAccount(childName, this.PASSWORD, attrs);
/* 1537 */       visibleCids.add(acct.getId());
/* 1538 */       cids.add(acct.getId());
/*      */       
/* 1540 */       attrs.clear();
/* 1541 */       childNameLocal = "iv-child-" + i;
/* 1542 */       childName = childNameLocal + "@" + this.DOMAIN_NAME;
/* 1543 */       this.mCustomProvTester.addAttr(attrs, this.BASE_DN_PSEUDO_ATTR, this.ACCT_BASE_DN);
/* 1544 */       this.mCustomProvTester.addAttr(attrs, this.ACCT_NAMING_ATTR, namingAttrValue(childNameLocal));
/* 1545 */       acct = this.mProv.createAccount(childName, this.PASSWORD, attrs);
/* 1546 */       invisibleCids.add(acct.getId());
/* 1547 */       cids.add(acct.getId());
/*      */     }
/*      */     
/* 1550 */     attrs.clear();
/* 1551 */     String childNameLocal = "not-child";
/* 1552 */     String childName = childNameLocal + "@" + this.DOMAIN_NAME;
/* 1553 */     this.mCustomProvTester.addAttr(attrs, this.BASE_DN_PSEUDO_ATTR, this.ACCT_BASE_DN);
/* 1554 */     this.mCustomProvTester.addAttr(attrs, this.ACCT_NAMING_ATTR, namingAttrValue(childNameLocal));
/* 1555 */     Account acctNotChild = this.mProv.createAccount(childName, this.PASSWORD, attrs);
/* 1556 */     String idNotChild = acctNotChild.getId();
/* 1557 */     Set<String> idsNotChild = new java.util.HashSet();
/* 1558 */     idsNotChild.add(idNotChild);
/*      */     
/* 1560 */     Set<String> temp = new java.util.HashSet();
/*      */     
/*      */ 
/* 1563 */     String parentNameLocal = "parent";
/* 1564 */     String parentName = parentNameLocal + "@" + this.DOMAIN_NAME;
/*      */     
/*      */     try
/*      */     {
/* 1568 */       attrs.clear();
/* 1569 */       this.mCustomProvTester.addAttr(attrs, this.BASE_DN_PSEUDO_ATTR, this.ACCT_BASE_DN);
/* 1570 */       this.mCustomProvTester.addAttr(attrs, this.ACCT_NAMING_ATTR, namingAttrValue(parentNameLocal));
/* 1571 */       attrs.put("zimbraChildAccount", cids);
/* 1572 */       attrs.put("zimbraPrefChildVisibleAccount", com.zimbra.common.util.SetUtil.union(temp, visibleCids, idsNotChild));
/* 1573 */       parent = this.mProv.createAccount(parentName, this.PASSWORD, attrs);
/* 1574 */       fail();
/*      */     } catch (ServiceException e) {
/* 1576 */       if (!e.getCode().equals("service.INVALID_REQUEST")) {
/* 1577 */         fail();
/*      */       }
/*      */     }
/*      */     
/* 1581 */     attrs.clear();
/* 1582 */     this.mCustomProvTester.addAttr(attrs, this.BASE_DN_PSEUDO_ATTR, this.ACCT_BASE_DN);
/* 1583 */     this.mCustomProvTester.addAttr(attrs, this.ACCT_NAMING_ATTR, namingAttrValue(parentNameLocal));
/* 1584 */     attrs.put("zimbraChildAccount", cids);
/* 1585 */     attrs.put("zimbraPrefChildVisibleAccount", visibleCids);
/* 1586 */     Account parent = this.mProv.createAccount(parentName, this.PASSWORD, attrs);
/*      */     
/*      */     try
/*      */     {
/* 1590 */       attrs.clear();
/* 1591 */       attrs.put("+zimbraPrefChildVisibleAccount", idsNotChild);
/*      */       
/* 1593 */       this.mProv.modifyAttrs(parent, attrs);
/* 1594 */       fail();
/*      */     } catch (ServiceException e) {
/* 1596 */       if (!e.getCode().equals("service.INVALID_REQUEST")) {
/* 1597 */         fail();
/*      */       }
/*      */     }
/*      */     
/* 1601 */     attrs.clear();
/* 1602 */     attrs.put("+zimbraChildAccount", idsNotChild);
/* 1603 */     attrs.put("+zimbraPrefChildVisibleAccount", idsNotChild);
/* 1604 */     this.mProv.modifyAttrs(parent, attrs);
/*      */     
/*      */ 
/* 1607 */     attrs.clear();
/* 1608 */     attrs.put("-zimbraChildAccount", idsNotChild);
/* 1609 */     this.mProv.modifyAttrs(parent, attrs);
/*      */     
/* 1611 */     Set<String> curAttrs = parent.getMultiAttrSet("zimbraPrefChildVisibleAccount");
/* 1612 */     assertFalse(curAttrs.contains(idsNotChild));
/*      */     
/*      */ 
/* 1615 */     attrs.clear();
/* 1616 */     attrs.put("zimbraChildAccount", "");
/* 1617 */     this.mProv.modifyAttrs(parent, attrs);
/*      */     
/* 1619 */     curAttrs = parent.getMultiAttrSet("zimbraPrefChildVisibleAccount");
/* 1620 */     assertEquals(0, curAttrs.size());
/*      */     
/*      */ 
/* 1623 */     for (String childId : cids)
/* 1624 */       this.mProv.deleteAccount(childId);
/* 1625 */     for (String childId : idsNotChild)
/* 1626 */       this.mProv.deleteAccount(childId);
/* 1627 */     this.mProv.deleteAccount(parent.getId());
/*      */   }
/*      */   
/*      */   private void flushCacheTest() throws Exception
/*      */   {
/* 1632 */     System.out.println("Testing flush cache");
/*      */     
/*      */ 
/* 1635 */     String value = null;
/* 1636 */     String newVal = "new value";
/* 1637 */     String oldVal = "old value";
/* 1638 */     Map<String, Object> attrs = new HashMap();
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1644 */     String acctAttr = "description";
/* 1645 */     Account acct = this.mSoapProv.get(Key.AccountBy.name, this.ACCT_EMAIL);
/* 1646 */     assertNotNull(acct);
/*      */     
/*      */ 
/* 1649 */     attrs.clear();
/* 1650 */     attrs.put(acctAttr, oldVal);
/* 1651 */     this.mSoapProv.modifyAttrs(acct, attrs);
/* 1652 */     acct = this.mSoapProv.get(Key.AccountBy.name, this.ACCT_EMAIL);
/* 1653 */     value = acct.getAttr(acctAttr);
/* 1654 */     assertEquals(oldVal, value);
/*      */     
/*      */ 
/* 1657 */     attrs.clear();
/* 1658 */     attrs.put(acctAttr, newVal);
/* 1659 */     acct = this.mProv.get(Key.AccountBy.name, this.ACCT_EMAIL);
/* 1660 */     this.mProv.modifyAttrs(acct, attrs);
/*      */     
/*      */ 
/* 1663 */     acct = this.mSoapProv.get(Key.AccountBy.name, this.ACCT_EMAIL);
/* 1664 */     value = acct.getAttr(acctAttr);
/* 1665 */     assertEquals(oldVal, value);
/*      */     
/*      */ 
/* 1668 */     this.mSoapProv.flushCache(com.zimbra.soap.admin.type.CacheEntryType.account, new com.zimbra.cs.account.Provisioning.CacheEntry[] { new com.zimbra.cs.account.Provisioning.CacheEntry(com.zimbra.common.account.Key.CacheEntryBy.id, acct.getId()) });
/*      */     
/*      */ 
/* 1671 */     acct = this.mSoapProv.get(Key.AccountBy.name, this.ACCT_EMAIL);
/* 1672 */     value = acct.getAttr(acctAttr);
/* 1673 */     assertEquals(newVal, value);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1679 */     String cosAttr = "zimbraPrefSkin";
/* 1680 */     Cos cos = this.mSoapProv.get(com.zimbra.common.account.Key.CosBy.name, this.COS_NAME);
/* 1681 */     assertNotNull(cos);
/*      */     
/*      */ 
/* 1684 */     attrs.clear();
/* 1685 */     attrs.put(cosAttr, oldVal);
/* 1686 */     this.mSoapProv.modifyAttrs(cos, attrs);
/* 1687 */     cos = this.mSoapProv.get(com.zimbra.common.account.Key.CosBy.name, this.COS_NAME);
/* 1688 */     value = cos.getAttr(cosAttr);
/* 1689 */     assertEquals(oldVal, value);
/*      */     
/*      */ 
/* 1692 */     attrs.clear();
/* 1693 */     attrs.put(cosAttr, newVal);
/* 1694 */     cos = this.mProv.get(com.zimbra.common.account.Key.CosBy.name, this.COS_NAME);
/* 1695 */     this.mProv.modifyAttrs(cos, attrs);
/*      */     
/*      */ 
/* 1698 */     cos = this.mSoapProv.get(com.zimbra.common.account.Key.CosBy.name, this.COS_NAME);
/* 1699 */     value = cos.getAttr(cosAttr);
/* 1700 */     assertEquals(oldVal, value);
/*      */     
/*      */ 
/* 1703 */     acct = this.mSoapProv.get(Key.AccountBy.name, this.ACCT_EMAIL);
/* 1704 */     value = acct.getAttr(cosAttr);
/* 1705 */     assertEquals(oldVal, value);
/*      */     
/*      */ 
/* 1708 */     this.mSoapProv.flushCache(com.zimbra.soap.admin.type.CacheEntryType.cos, new com.zimbra.cs.account.Provisioning.CacheEntry[] { new com.zimbra.cs.account.Provisioning.CacheEntry(com.zimbra.common.account.Key.CacheEntryBy.id, cos.getId()) });
/*      */     
/*      */ 
/* 1711 */     cos = this.mSoapProv.get(com.zimbra.common.account.Key.CosBy.name, this.COS_NAME);
/* 1712 */     value = cos.getAttr(cosAttr);
/* 1713 */     assertEquals(newVal, value);
/*      */     
/*      */ 
/* 1716 */     acct = this.mSoapProv.get(Key.AccountBy.name, this.ACCT_EMAIL);
/* 1717 */     value = acct.getAttr(cosAttr);
/* 1718 */     assertEquals(newVal, value);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1723 */     String configAttr = "zimbraWebClientLoginUrl";
/* 1724 */     com.zimbra.cs.account.Config config = this.mSoapProv.getConfig();
/* 1725 */     assertNotNull(config);
/*      */     
/*      */ 
/* 1728 */     attrs.clear();
/* 1729 */     attrs.put(configAttr, oldVal);
/* 1730 */     this.mSoapProv.modifyAttrs(config, attrs);
/* 1731 */     config = this.mSoapProv.getConfig();
/* 1732 */     value = config.getAttr(configAttr);
/* 1733 */     assertEquals(oldVal, value);
/*      */     
/*      */ 
/* 1736 */     attrs.clear();
/* 1737 */     attrs.put(configAttr, newVal);
/* 1738 */     config = this.mProv.getConfig();
/* 1739 */     this.mProv.modifyAttrs(config, attrs);
/*      */     
/*      */ 
/* 1742 */     config = this.mSoapProv.getConfig();
/* 1743 */     value = config.getAttr(configAttr);
/* 1744 */     assertEquals(oldVal, value);
/*      */     
/*      */ 
/* 1747 */     this.mSoapProv.flushCache(com.zimbra.soap.admin.type.CacheEntryType.config, null);
/*      */     
/*      */ 
/* 1750 */     config = this.mSoapProv.getConfig();
/* 1751 */     value = config.getAttr(configAttr);
/* 1752 */     assertEquals(newVal, value);
/*      */   }
/*      */   
/*      */   private void attributeInheritanceTest() throws Exception {
/* 1756 */     System.out.println("Testing attribute inheritance");
/*      */     
/* 1758 */     Account acct = this.mProv.get(Key.AccountBy.name, this.ACCT_EMAIL);
/* 1759 */     assertNotNull(acct);
/*      */     
/* 1761 */     Cos cos = this.mProv.getCOS(acct);
/* 1762 */     assertNotNull(cos);
/*      */     
/* 1764 */     Domain domain = this.mProv.getDomain(acct);
/* 1765 */     assertNotNull(domain);
/*      */     
/* 1767 */     String attr = "zimbraPrefSkin";
/*      */     
/* 1769 */     Map<String, Object> attrs = new HashMap();
/* 1770 */     attrs.clear();
/* 1771 */     attrs.put(attr, "account-value");
/* 1772 */     this.mProv.modifyAttrs(acct, attrs);
/*      */     
/* 1774 */     attrs.clear();
/* 1775 */     attrs.put(attr, "cos-value");
/* 1776 */     this.mProv.modifyAttrs(cos, attrs);
/*      */     
/* 1778 */     attrs.clear();
/* 1779 */     attrs.put(attr, "domain-value");
/* 1780 */     this.mProv.modifyAttrs(domain, attrs);
/*      */     
/*      */ 
/* 1783 */     String val = acct.getAttr(attr);
/* 1784 */     assertEquals("account-value", val);
/*      */     
/*      */ 
/* 1787 */     attrs.clear();
/* 1788 */     attrs.put(attr, "");
/* 1789 */     this.mProv.modifyAttrs(acct, attrs);
/*      */     
/* 1791 */     val = acct.getAttr(attr);
/* 1792 */     assertEquals("cos-value", val);
/*      */     
/*      */ 
/* 1795 */     attrs.clear();
/* 1796 */     attrs.put(attr, "");
/* 1797 */     this.mProv.modifyAttrs(cos, attrs);
/*      */     
/* 1799 */     val = acct.getAttr(attr);
/* 1800 */     assertEquals("domain-value", val);
/*      */     
/*      */ 
/* 1803 */     attrs.clear();
/* 1804 */     attrs.put(attr, "");
/* 1805 */     this.mProv.modifyAttrs(domain, attrs);
/*      */     
/* 1807 */     val = acct.getAttr(attr);
/* 1808 */     assertEquals(null, val);
/*      */   }
/*      */   
/*      */   private Set<String> getAvailableSkins_prior_bug31596(Account acct)
/*      */     throws ServiceException
/*      */   {
/* 1814 */     Set<String> skins = acct.getMultiAttrSet("zimbraAvailableSkin");
/* 1815 */     if (skins.size() > 0) {
/* 1816 */       return skins;
/*      */     }
/*      */     
/* 1819 */     Domain domain = Provisioning.getInstance().getDomain(acct);
/* 1820 */     if (domain == null)
/* 1821 */       return skins;
/* 1822 */     return domain.getMultiAttrSet("zimbraAvailableSkin");
/*      */   }
/*      */   
/*      */   private void attributeInheritanceTestMultiValue_prior_bug31596() throws Exception {
/* 1826 */     System.out.println("Testing attribute inheritance multi-value prior bug31596");
/*      */     
/* 1828 */     Account acct = this.mProv.get(Key.AccountBy.name, this.ACCT_EMAIL);
/* 1829 */     assertNotNull(acct);
/*      */     
/* 1831 */     Domain domain = this.mProv.getDomain(acct);
/* 1832 */     assertNotNull(domain);
/*      */     
/* 1834 */     String attr = "zimbraAvailableSkin";
/*      */     
/* 1836 */     Map<String, Object> attrs = new HashMap();
/* 1837 */     attrs.clear();
/* 1838 */     attrs.put("+" + attr, new String[] { "domain-value-1", "domain-value-2" });
/* 1839 */     this.mProv.modifyAttrs(domain, attrs);
/*      */     
/*      */ 
/* 1842 */     Set<String> val = getAvailableSkins_prior_bug31596(acct);
/* 1843 */     TestProvisioningUtil.verifyEntries(val, new String[] { "domain-value-1", "domain-value-2" }, true);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   private void attributeInheritanceTestMultiValue()
/*      */     throws Exception
/*      */   {
/* 1853 */     System.out.println("Testing attribute inheritance multi-value");
/*      */     
/* 1855 */     Account acct = this.mProv.get(Key.AccountBy.name, this.ACCT_EMAIL);
/* 1856 */     assertNotNull(acct);
/*      */     
/* 1858 */     Domain domain = this.mProv.getDomain(acct);
/* 1859 */     assertNotNull(domain);
/*      */     
/* 1861 */     String attr = "zimbraAvailableSkin";
/*      */     
/* 1863 */     Map<String, Object> attrs = new HashMap();
/* 1864 */     attrs.clear();
/* 1865 */     attrs.put("+" + attr, new String[] { "domain-value-1", "domain-value-2" });
/* 1866 */     this.mProv.modifyAttrs(domain, attrs);
/*      */     
/*      */ 
/* 1869 */     Set<String> val = acct.getMultiAttrSet(attr);
/* 1870 */     TestProvisioningUtil.verifyEntries(val, new String[] { "domain-value-1", "domain-value-2" }, true);
/*      */   }
/*      */   
/*      */   private void loadTest() throws Exception {
/* 1874 */     System.out.println("Testing load");
/*      */     
/*      */ 
/* 1877 */     String domainName = "load-test." + this.DOMAIN_NAME;
/* 1878 */     Domain domain = this.mProv.createDomain(domainName, new HashMap());
/*      */     
/* 1880 */     int numAccts = 5000;
/* 1881 */     Account acct; for (int a = 0; a < numAccts; a++) {
/* 1882 */       String acctName = "acct-" + (a + 1) + "@" + domainName;
/* 1883 */       System.out.println("creating account" + acctName);
/* 1884 */       acct = this.mProv.createAccount(acctName, this.PASSWORD, new HashMap());
/*      */     }
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */   private String execute()
/*      */     throws Exception
/*      */   {
/* 1893 */     healthTest();
/* 1894 */     com.zimbra.cs.account.Config config = configTest();
/* 1895 */     String cosName = cosTest();
/* 1896 */     String[] domainNames = domainTest();
/* 1897 */     String domainName = domainNames[0];
/* 1898 */     String otherDomainName = domainNames[1];
/* 1899 */     String specialCharDomainName = domainNames[2];
/* 1900 */     mimeTest();
/* 1901 */     com.zimbra.cs.account.Server server = serverTest();
/* 1902 */     com.zimbra.cs.account.Zimlet zimlet = zimletTest();
/*      */     
/* 1904 */     Account adminAccount = adminAccountTest();
/* 1905 */     Account[] accounts = accountTest(adminAccount, this.mProv.get(com.zimbra.common.account.Key.CosBy.name, cosName), this.mProv.get(com.zimbra.common.account.Key.DomainBy.name, domainName), this.mProv.get(com.zimbra.common.account.Key.DomainBy.name, otherDomainName));
/* 1906 */     Account account = accounts[0];
/* 1907 */     authTest(account);
/* 1908 */     passwordTest(account);
/* 1909 */     localeTest();
/*      */     
/* 1911 */     com.zimbra.cs.account.CalendarResource calendarResource = calendarResourceTest(this.mProv.get(com.zimbra.common.account.Key.CosBy.name, cosName), this.mProv.get(com.zimbra.common.account.Key.DomainBy.name, domainName));
/*      */     
/* 1913 */     DistributionList[] distributionLists = distributionListTest(this.mProv.get(com.zimbra.common.account.Key.DomainBy.name, domainName));
/* 1914 */     com.zimbra.cs.account.DataSource dataSource = dataSourceTest(account);
/* 1915 */     com.zimbra.cs.account.Identity identity = identityTest(account);
/* 1916 */     signatureTest(account);
/*      */     
/* 1918 */     entryTest(account);
/* 1919 */     galTest(this.mProv.get(com.zimbra.common.account.Key.DomainBy.name, domainName));
/* 1920 */     searchTest(this.mProv.get(com.zimbra.common.account.Key.DomainBy.name, domainName));
/*      */     
/* 1922 */     Domain aliasTestDomain = aliasTest();
/* 1923 */     familyTest();
/* 1924 */     flushCacheTest();
/* 1925 */     attributeInheritanceTest();
/* 1926 */     attributeInheritanceTestMultiValue_prior_bug31596();
/* 1927 */     attributeInheritanceTestMultiValue();
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1932 */     System.out.println("\nPress enter to delete entries created by the test");
/*      */     
/* 1934 */     String line = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)).readLine();
/* 1935 */     System.out.println("\nDeleting entries");
/*      */     
/* 1937 */     this.mProv.deleteZimlet(this.ZIMLET_NAME);
/* 1938 */     this.mProv.deleteServer(server.getId());
/* 1939 */     this.mProv.deleteIdentity(account, this.IDENTITY_NAME);
/* 1940 */     this.mProv.deleteDataSource(account, dataSource.getId());
/*      */     
/*      */ 
/* 1943 */     for (DistributionList dl : distributionLists)
/*      */     {
/*      */ 
/*      */ 
/*      */ 
/* 1948 */       String defaultDomain = this.mProv.getConfig().getAttr("zimbraDefaultDomainName");
/* 1949 */       if ((this.mCustomProvTester.isCustom()) && (dl.getDomainName().equals(this.DOMAIN_NAME_SPECIAL_CHARS))) {
/* 1950 */         setDefaultDomain(this.DOMAIN_NAME_SPECIAL_CHARS);
/*      */       }
/* 1952 */       this.mProv.deleteDistributionList(dl.getId());
/*      */       
/* 1954 */       if ((this.mCustomProvTester.isCustom()) && (dl.getDomainName().equals(this.DOMAIN_NAME_SPECIAL_CHARS))) {
/* 1955 */         setDefaultDomain(defaultDomain);
/*      */       }
/*      */     }
/* 1958 */     this.mProv.deleteCalendarResource(calendarResource.getId());
/*      */     
/* 1960 */     for (Account acct : accounts)
/* 1961 */       this.mProv.deleteAccount(acct.getId());
/* 1962 */     this.mProv.deleteAccount(adminAccount.getId());
/*      */     
/* 1964 */     this.mProv.deleteDomain(this.mProv.get(com.zimbra.common.account.Key.DomainBy.name, domainName).getId());
/* 1965 */     this.mProv.deleteDomain(this.mProv.get(com.zimbra.common.account.Key.DomainBy.name, otherDomainName).getId());
/* 1966 */     this.mProv.deleteDomain(this.mProv.get(com.zimbra.common.account.Key.DomainBy.name, specialCharDomainName).getId());
/* 1967 */     this.mProv.deleteDomain(aliasTestDomain.getId());
/* 1968 */     this.mProv.deleteCos(this.mProv.get(com.zimbra.common.account.Key.CosBy.name, cosName).getId());
/*      */     
/* 1970 */     System.out.println("\nAll done");
/* 1971 */     return this.TEST_ID;
/*      */   }
/*      */   
/*      */   public void testProvisioning() throws Exception
/*      */   {
/*      */     try {
/* 1977 */       System.out.println("\nTest " + this.TEST_ID + " starting\n");
/* 1978 */       execute();
/* 1979 */       System.out.println("\nTest " + this.TEST_ID + " done!");
/*      */     } catch (ServiceException e) {
/* 1981 */       Throwable cause = e.getCause();
/* 1982 */       System.out.println("ERROR: " + e.getCode() + " (" + e.getMessage() + ")" + (cause == null ? "" : new StringBuilder().append(" (cause: ").append(cause.getClass().getName()).append(" ").append(cause.getMessage()).append(")").toString()));
/*      */       
/* 1984 */       e.printStackTrace(System.out);
/* 1985 */       System.out.println("\nTest " + this.TEST_ID + " failed!");
/*      */     } catch (junit.framework.AssertionFailedError e) {
/* 1987 */       System.out.println("\n===== assertion failed =====");
/* 1988 */       System.out.println(e.getMessage());
/* 1989 */       e.printStackTrace(System.out);
/*      */     }
/*      */   }
/*      */   
/*      */   public static void main(String[] args) throws Exception
/*      */   {
/* 1995 */     com.zimbra.common.util.CliUtil.toolSetup("WARN");
/*      */     
/*      */ 
/*      */ 
/* 1999 */     TestProvisioning t = new TestProvisioning();
/* 2000 */     t.setUp();
/* 2001 */     t.execute();
/*      */   }
/*      */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/qa/unittest/TestProvisioning.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */